Re: Using wildcards in string comparison
Re: Using wildcards in string comparison
- Subject: Re: Using wildcards in string comparison
- From: Charilaos Skiadas <email@hidden>
- Date: Mon, 11 Apr 2005 18:27:30 -0500
On Apr 11, 2005, at 3:24 PM, jjoonathan wrote:
Charilaos Skiadas wrote:
On Apr 11, 2005, at 12:58 AM, Jiva DeVoe wrote:
Sounds like you probably want some regexp capabilities.
I think (have not searched google) that omni has some frameworks
that do this. If not, I think MOKit does.
On Apr 10, 2005, at 1:06 PM, jjoonathan wrote:
I am making an app which allows an array to be searched by a string
which contains wildcards (the *, and ?, etc). I am currently using
the isLike: method of NSString, but I ran into a problem. I want
the search string to be able to contain [ and ] characters that
are not part of the pattern. So, @"*[ABC]*" would match
@"123[ABC]456", not @"123[A]456", @"123[B]456", or @"123[C]456".
Any ideas? Is there another method which allows comparisons just
by wildcards?
You can try escaping the brackets, i.e. maybe this might work:
@"123\[ABC\]456". Haven't tried it though, just the obvious guess.
Thanks in advance,
jjoonathan
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
email@hidden
This email sent to email@hidden
--
Jiva DeVoe
http://www.devoesquared.com
PowerCard - Intuitive Project Management for Mac OS X
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
email@hidden
This email sent to email@hidden
Haris
Thanks for your help, but I just found out it works for me to replace
all of the braces with curly ones and then do the comparisons, and
that works. Now, however, it seems that isCaseInsensitiveLike: goes
into an infinite loop sometimes. Its really confusing, because its
never on the same string (these are NSMutableStrings I am comparing,
by the way, that are from three to twenty characters long). Is this a
common mistake that I am making? Or is this something that is just a
bug and I should go with the other frameworks (I would prefer to not
use any non-apple frameworks, but if I must, I must...)
Is there a reason you are not using NSScanner for this? I have never
used isLike and friends before, in fact, I haven't heard of anyone
using them before either. If the strings really have the simple form
you described above, I would just roll my own method for it.
Ok, maybe NSScanner might be too heavy for the job, but just wrap it
around your own method, and if you see it slows down your app during
the optimization phase, you can then look for another way.
Best,
Haris
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden