reMatch returns an array of matches

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 }.

Categories: ColdFusion

About The Author

My name is Dan Vega and I am a Software Developer based out of Cleveland OH. I love to play with new technologies and write about my experiences here. When I am not busy being a full time geek I love to lift heavy weights and hang out with friends and family. If you have any questions please don't hesitate to contact me.

Follow me on:
  • Adam Cameron

    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

  • http://www.bennadel.com Ben Nadel

    reMatch() is pretty awesome.

  • http://www.figleaf.com John Allen

    Sharp.

  • http://zacster.blogspot.com/ zac spitzer

    interesting stuff, i could see myself using this to parsing up html

  • http://therealdanvega.com Dan Vega

    Indeed! It is very handy and I only wish I knew about it earlier.