Reputation: 17332
I try to replace all variations of these tags with a whitespace:
<text:s></text:s>
<text:s/>
<text:s anyattributes/>
But <text:span>
shouldn't be affected.
preg_replace("/<\\/?text:s(\\s+.*?>|>)/", " ", $string);
What am I doing wrong?
Upvotes: 1
Views: 34
Reputation: 174706
Use the below regex and replace the match with a space.
<\/?text:s\b[^<>]*>
code would be,
preg_replace("~<\/?text:s\b[^<>]*>~", " ", $string);
\b
word boundary helps you to get the job done. Since \b
matches between a word and a non-word character, the above regex won't match the string <text:span>
because there isn't a word boundary exists between s
and p
Upvotes: 1