servsn i have a question about regex.....
i want to implement a new "forumstag" called --> [color="#00ff00"]colored text[/color]
for that i use a new function....
as far as it works fine but there is a bug
if someone writes 3 false tags like -->
[color="#00ffsdafasdfasdf00"]colored text[/color]
[color="#00ff00"]colored text[/cafdsafafaolor]
[coadfafaslor="#00ff00"]colored text[/color]
and wirtes after that a right color tag the first wrong tag
will be written in a right html tag and the html font tag will be opend....
so someone can enter some other html tags
is there a better regex or have i wrote an error in the "replace" line?..
thanks in advance for help
function ReplaceFontColor(fString)
Set regEx = New RegExp
regEx.Pattern = "\[color=("")(\#)([a-fA-F0-9]{6})("")\](.*?)\[/color\]"
regEx.Global = True
Set Matches = regEx.Execute(fString)
if matches.count <> 0 then
for each match in matches
changecolor = Replace(Replace(Replace(match.value,"[color=""","<font color="""),"""]",""">"),"[/color]","</font>")
fstring = Replace(fstring, match.value, changecolor)
next
end if
ReplaceFontColor = fstring
Set regEx = Nothing
end function
==================================================
a demo of this function is available under
http://sonic.selfip.org
Login: Network
Pass: network
se it under Gästebuch and the link upper left eintragen
click on the blue "B" button for coloring some words...