I feel I’m very close to what I’m trying to achieve but can’t quite get it right for VBScript
This expression works great for my use case but only with the ‘single line’ flag enabled which VBScript doesn’t seem to support:
<a\s* href="https:\/\/www.facebook.com\/TestCo\/">(.*?) </span>
I tried this to get around it but then I end up selecting too much of the text..
<a\s* href="https:\/\/www.facebook.com\/TestCo\/">([\s\S]*) </span>
I’m trying to match and remove this line from the full text below:
<a href="https://www.facebook.com/TestCo/"><span
style='font-size:14.0pt;font-family:"Times New Roman","serif";color:black;
text-decoration:none;text-underline:none'><img border=0 width=19 height=19
id="_x0000_i1026" src="Images/image002.png"></span></a><span
style='font-size:14.0pt'> </span>
Here is the text I’m working with
style='font-size:14.0pt;font-family:"Times New Roman","serif";color:black;
text-decoration:none;text-underline:none'><img border=0 width=19 height=19
id="_x0000_i1026" src="Images/image002.png"></span></a><span
style='font-size:14.0pt'> </span><a
href="https://www.linkedin.com/company/TestCo/"><span
style='font-size:14.0pt;font-family:"Times New Roman","serif";color:black;
text-decoration:none;text-underline:none'><img border=0 width=19 height=19
id="_x0000_i1027" src="Images/image004.png"></span></a><span
style='font-size:14.0pt'> </span><a
href="https://twitter.com/TestCo"><span style='font-size:14.0pt;
font-family:"Times New Roman","serif";color:black;text-decoration:none;
text-underline:none'><img border=0 width=19 height=19 id="_x0000_i1028"
src="Images/image006.png"></span></a><o:p></o:p></p>
Thank you
>Solution :
Dim regex: Set regex = New RegExp
regex.MultiLine = False
regex.Pattern = "<a\s* href=""https:\/\/www.facebook.com\/TestCo\/"">(.*?) </span>"
newString = regex.Replace(text, "")
Or if you want to match across multiple lines:
Dim regex: Set regex = New RegExp
regex.MultiLine = False
regex.Pattern = "<a\s* href=""https:\/\/www.facebook.com\/TestCo\/"">([\s\S]*?) </span>"
newString = regex.Replace(text, "")