guidence through the swamp of regular expressions

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
compound_eye
Forum Newbie
Posts: 15
Joined: Wed Mar 17, 2004 8:42 pm

guidence through the swamp of regular expressions

Post by compound_eye »

in my previous post:

search and replace : how does [url=http://somewhere] work?

i was asking about search and replace,
the essence of the question is

if i seach for the pattern {:tag:}
where tag is a specified name such as 'text'

{:text:}

and there can be whitespace and more text after x, but before the colon

{:tag extraStuff)

{:text bold:}
{:username red:}

is there a way i can use regular expressions
1: to find the pattern,
2: extract the 'extraStuff',
3: put together a new string using the extraStuff
4: then replace the tag with the new string?

if it makes any difference i can
change the format of the tag

eg

{:tag: extraStuff}
or
{:tag:}#extraStuff#

whatever works and is straight forward

cheers, mat
Post Reply