3

How do I remove a span tag using a VBScript regex? For example, the following HTML should be reduced to just the h3 opening tag:

<h3><span style="color: inherit; font-size: 24px; line-height: 1.1;">

It must be by regex, as it is part of a regex process to standardize text. The content of the span can vary totally, and most of the time there is no span.

Bond
  • 16,071
  • 6
  • 30
  • 53
Paul
  • 117
  • 2
  • 9

1 Answers1

2

You should be able to use the pattern <span [^>]*> to match the opening tag (<span) and then grab everything up to the closing >.

Dim s
s = "<h3><span style=""color: inherit; font-size: 24px; line-height: 1.1;"">"

With New RegExp
    .Pattern = "<span [^>]*>"
    s = .Replace(s, "")
End With
Bond
  • 16,071
  • 6
  • 30
  • 53
  • That worked, thanks indeed! I had to add the tag h3 before in the pattern to avoid all the span tags from being stripped out in the rest of the document. Sorry it seems I can't click to give one. – Paul Jul 21 '15 at 23:30