Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

html

regex

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.

like image 751
Sharkus Avatar asked Dec 08 '22 08:12

Sharkus


1 Answers

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

like image 57
Allan S. Hansen Avatar answered May 21 '23 15:05

Allan S. Hansen