Page 1 of 1

pattern matching

Posted: Fri Mar 18, 2005 11:56 am
by hongco
hi,

I've been tryign to get some good info on pattern matching using the function preg_replace(), but hardly got any good ones. What i was trying to do should be quite simple; however, i am still new to patterns.

I tried to replace this pattern:

:string: with img file, just like the smilies icons on phpbb :)

string could be any character 0-9, a-z, A-Z, -, _
and the string is between colons,
in the front of both colons ( : ) should be a white space.

Thanks :)

Posted: Fri Mar 18, 2005 12:16 pm
by timvw
why don't you use the bbcode then?

otherwise the re would look like "# :\w+: #"

Posted: Fri Mar 18, 2005 12:22 pm
by hongco
hi Tim,

yah, i was thinking about using bbcodes. I still need to find more tutorial on pattern matching. :)

Thanks!

Posted: Fri Mar 18, 2005 10:17 pm
by feyd
follow the links about regex in the useful posts thread, and in the starter pack..