Reputation: 147
I have the following text.
<span style="color:#FF0000;">赤色</span><span style="color:#0;">|*|</span><span style="color:#0070C0;">青色</span><span style="color:#0;">|*|</span><span style="color:#00B050;">緑色</span><span style="color:#0;">|*|</span>
I need to remove any span tag that defines color for "|*|" only. That is in this case, I need to remove
<span style="color:#0;">
and
</span>
Can anyone help to do that?
Thanks in advance!
Upvotes: 0
Views: 678
Reputation: 44831
You want something like this:
<span[^>]+style="[^"]*color:[^>]+>(\|\*\|)<\/span>
This matches <span
, then one or more non->
characters, then a style
attribute that contains color:
, then the rest of the tag, then |*|
, then </span>
.
You would replace with $1
or just |*|
.
Note: one reason your attempt didn't work is that you escaped the |
s, but not the *
. You need to escape the *
as \*
.
Upvotes: 1