Page 1 of 1

Simple Regexp

Posted: Sun Mar 29, 2009 12:24 am
by Walid
Can someone help me figure out the regex to use with preg_match_all to identify all the "words" shown below (i.e. hi, bye, friend).

Code: Select all

 
Bla bla bla
{some:word=hi}
Bla bla bla
{some:word=bye}
Bla bla bla
{some:word=friend}
Bla bla bla
 
Thanks

Re: Simple Regexp

Posted: Sun Mar 29, 2009 12:54 am
by requinix
Here's the pattern you want to use.

Code: Select all

'/\{some:word=([^}]+)\}/i'
You can change "some:word" to anything with letters, numbers, or !@#%&-_=:;"'<,>
You can use other symbols but they must be escaped with a \ (like you do with quotes inside strings).

Now see if you can't figure the rest out yourself ;)

Re: Simple Regexp

Posted: Mon Mar 30, 2009 4:44 am
by Walid
Thanks. Perfect.