Hey guys. I've spent hours today working the impossible trying to do the simple. Normal coding affair.
What I've got is text input where I've chosen to except certain forum styles of formatting, aka
Exactly like the code tags I just used.
This is somewhat like the post over at
Currently I have it working fine for the easy ones etc, but for complicated tags like colour/size/link/email it gets fiddly. I have it working if I replace the first tag seperately from the last, eg
But me being me I stubbornly wanted to do it all in 1 go. But nowhere can I find a way to specify the section in the middle of the pattern (the bits between the tags to be formatted) to be "any char but NOT the closing tag sequence eg [/colour]".
For example, since it's greedy patterning, this will format from the first opening tag to the last closing tag
Now I've tried making that crucial middle bit (.+) into all sorts, but I just can't get it to look for the closing tag, thanks to [ and ] being stuff to do with patterns. Typical eh?
Please help! ;_;
_________________________________
Leozack
What I've got is text input where I've chosen to except certain forum styles of formatting, aka
Code:
[heading]This Is A Heading[/heading]
[linebreak]
[b]Bold text here[/b] [i]Italic text here[/i] [u]Underlined text here[/u]
[colour='red']Coloured text here[/colour] (colour from red/blue/yellow/purple/green/orange/white/black)
[size='1']Small text here[/size] (size from 1-10)
[link='[URL unfurl="true"]http://www.test.com'[/URL]]Click here[/url]
[email='address']Email us[/email] (will goto 'address')
This is somewhat like the post over at
Currently I have it working fine for the easy ones etc, but for complicated tags like colour/size/link/email it gets fiddly. I have it working if I replace the first tag seperately from the last, eg
Code:
$thetext = ereg_replace("\[colour='([^']+)']","<font color=\"\\1\">",$thetext);
$thetext = ereg_replace("\[/colour]","</font>",$thetext);
For example, since it's greedy patterning, this will format from the first opening tag to the last closing tag
Code:
$thetext = ereg_replace("\[colour='([^']+)'](.+)\[/colour]","<font color=\"\\1\">\\2</font>",$thetext);
Please help! ;_;
_________________________________
Leozack
Code:
MakeUniverse($infinity,1,42);