-
regex trouble
Hi all,
I am currently trying to convert a bunch of html files. I am using regular expresions to do that.
I am converting a set of Font tags
Here's a sample
<FONT FACE="MathematicalPi 1></FONT> || &plus
<FONT FACE="MathematicalPi 1>1</FONT> || +
<FONT FACE="MathematicalPi 1>2</FONT> || −
<FONT FACE="MathematicalPi 4>2</FONT> || <b>−</b>
<FONT FACE="Univ GreekwMathPi>.</FONT> || >
<FONT FACE="Univ NewswCommPi>r</FONT> || ©
My replacement is to work like this
1.Search font face upto the closing tag - example:<FONT FACE="MathematicalPi 1......>
2.Search Entity value - example 1 (as in <FONT FACE="MathematicalPi 1>1</FONT> )
3.Replace the the whole string <font....upto </font with the replacement character - example &plus
Here's the code that i tried
Code:
Sub FontR()
'Debug.Print ReplaceTags("<font face=""mathematical pi 1"" color=""#000000""> 1</font>", "<font face=""mathematical pi 1""", "1", "&plus")
End Sub
Function ReplaceTags(ByVal ReplaceIn As String, ByVal Replaceend As String, ByVal SearchFor As String, ByVal Replacement As String) As String
Dim re As RegExp
Dim s As String
Set re = New RegExp
re.Pattern = Repend & "(.|\n)*>(\s)*" & SearchFor & "(\s)*</FONT>"
re.Global = True
re.IgnoreCase = True
s = re.Replace(ReplaceIn, " " & Replacement)
ReplaceTags = s
End Function
But its not replacing....When i debugged it showed the correct values but it did not replace the string