reMatch returns an array of matches

Word Count: 120

I don't know why but I just found out how useful rematch can be this week. The rematch function will take a regular expression, a string to search and then return to you an array of matches. In my case I was reading a file and searching for a specific string. Let's take a look at this example and just how useful it can be. The data is piece out of the template I was reading. The regular expression "{[^{]+}" will find the text between { and }.

Comments

#1 Posted By: zac spitzer Posted On: 9/18/09 12:49 AM
interesting stuff, i could see myself using this to parsing up html
#2 Posted By: Dan Vega Posted On: 9/18/09 7:32 AM |
Author Comment
Indeed! It is very handy and I only wish I knew about it earlier.
#3 Posted By: John Allen Posted On: 9/18/09 9:15 AM
Sharp.
#4 Posted By: Ben Nadel Posted On: 9/18/09 11:25 AM
reMatch() is pretty awesome.
#5 Posted By: Adam Cameron Posted On: 9/18/09 4:38 PM
I see the usefulness of reMatch() as being fairly limited, given it doesn't support the return of matched subexpressions like reFind() does. It's pretty rare that I don't also want to match subexpressions when using regexes, and in not doing this, it's rendered useless for all except fairly basic situations.

It seems to me like it's a half-finished solution.

Still: something that's half-finished does have the scope to be finished one day, I guess.

--
Adam


Post Your Comment

Leave this field empty







Show Captcha

If you subscribe, any new posts to this thread will be sent to your email address.

Copyright © 2007 Dan Vega | BlogCFC was created by Raymond Camden. This blog is running version 5.8.001.