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:
- /test/abc -> yes
- /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):
- i store path parent, not full 1 along name. name gets stored in different field (to full path stitch 2 strings together)
- 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
Post a Comment