pattern matching

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
hongco
Forum Contributor
Posts: 186
Joined: Sun Feb 20, 2005 2:49 pm

pattern matching

Post 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 :)
timvw
DevNet Master
Posts: 4897
Joined: Mon Jan 19, 2004 11:11 pm
Location: Leuven, Belgium

Post by timvw »

why don't you use the bbcode then?

otherwise the re would look like "# :\w+: #"
hongco
Forum Contributor
Posts: 186
Joined: Sun Feb 20, 2005 2:49 pm

Post by hongco »

hi Tim,

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

Thanks!
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

follow the links about regex in the useful posts thread, and in the starter pack..
Post Reply