Sharkus
Sharkus

Reputation: 175

Regex to remove only span tags but preserve content found within them

I have a span tag like this:

<span id="item.2.2">3 October.--As I must do something or go mad, I write this diary.</span>

I'd like to be able to remove the open and closing span but leave the text within it. In addition the id part of the opening span does change, so it could be item.10.2 or item.100.5 so I would need to take that into account.

** edit ** Edited to add. The file(s) I'd want to replace this in also have span tags that of not include the id specifier and I do NOT want to remove them, or their closing , sorry I should have said that earlier.

Upvotes: 4

Views: 7633

Answers (1)

Allan S. Hansen
Allan S. Hansen

Reputation: 4081

Do a regex which replaces </?span[^>]*> with empty string

Upvotes: 15

Related Questions