PDA

View Full Version : escape wildcard in matchpattern


Gravey
07-08-2011, 03:32 AM
say i have a string with a * in it, something like "something * blah" and I want to match it exactly, could I do it with matchpattern by escaping the wildcard * to be an exact match?

for example:
-- want this to be true
matchpattern "something * blah" pattern:"something * blah"
-- do NOT want this to be true
matchpattern "something 12345 blah" pattern:"something * blah" something like toLower a == toLower b would probably work in this case but the string i'm trying to match might be in the middle of a string. I could use regular expressions but i think this might be quicker to write, also i'm interested if it's possible.

denisT
07-08-2011, 03:46 AM
say i have a string with a * in it, something like "something * blah" and I want to match it exactly, could I do it with matchpattern by escaping the wildcard * to be an exact match?

for example:
-- want this to be true
matchpattern "something * blah" pattern:"something * blah"
-- do NOT want this to be true
matchpattern "something 12345 blah" pattern:"something * blah" something like toLower a == toLower b would probably work in this case but the string i'm trying to match might be in the middle of a string. I could use regular expressions but i think this might be quicker to write, also i'm interested if it's possible.
do use the regular expressions, it's exactly the case

lo
07-08-2011, 07:37 AM
this is a somewhat legitimate workaround without regex
matchpattern (substituteString "something * blah" "*" "#") pattern:"something # blah"

unless of course the original string is "something # blah", in which case you will get a false positive.

CGTalk Moderation
07-08-2011, 07:37 AM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.