regex - How to reproduce MATCHES in NSPredicate to query Realm? -


i have query using nspredicate takes regular expression , matches paths:

let predicate = nspredicate(format: "path matches '/test/([^/]*[^/])$'") 

which matches inside folder test excludes subfolders of folders in test, this:

  1. /test/abc -> yes
  2. /test/abc/def -> no

the problem is, can't use match keyword of nspredicate in realm.io. how can reproduce query works in realm?

adding exception completeness:

*** terminating app due uncaught exception 'invalid operator type', reason: 'operator type 6 not supported string type'

so have solved problem (modifying model, wanted avoid):

  1. i store path parent, not full 1 along name. name gets stored in different field (to full path stitch 2 strings together)
  2. instead of matching regular expression use nspredicate(format: "path ==[c] %@", "/test/") contents of folder test.

why not totally happy solution:

i wanted avoid separating field fullpath 2 fields because when file gets renamed + moved, it's 1 operation - rewrite fullpath in database. may seem minor problem, having 1 place of responsibility gave bit more robustness, because files moved , renamed time in environment of app.


Comments

Popular posts from this blog

Java 3D LWJGL collision -

spring - SubProtocolWebSocketHandler - No handlers -

methods - python can't use function in submodule -