0

Regex works outside pipe but not inside - how can I proceed?

After having done some manipulation in a pipe, I can end up with the following empty link and image source (which I want to replace with nothing, i.e. remove:

<a><img alt="" style="<width:16.66%;>" title=""></a>

Using RegExr.com I can see that the following matches it just fine

<a[^>]*><img.alt=""[^>]*>[^>]*>

...but when I use that in the pipe where the empty link and image source are, it doesn't match - or doesn't do the replace.

What can I do to force the match and replace?

I haven't given a pipe link because this happens so rarely that it's almost impossible to see happen in the first place!

by
6 Replies
  • hello,

    try \> and \< instead of their backslash-less equivalents, I noticed that it helps.

    1
  • Thanks Lolo, I'll give that a try :)

    0
  • Ah, no, it didn't :(

    I'll approach it differently. Thanks anyway, Lolo.

    Onwards....

    ~~Mark

    0
  • I only had a quick look yesterday. looking at your expression now, I have some information for you: in an xml file (hence a feed) the content < and > are replaced by &lt; and &gt; to not interfere with the functional ones. However the pipe regex might interpret those codes. Does the current regex matches up to the img's > ?

    0
  • Hey Lolo, thanks for the added info. My workaround worked out (different approach entirely!) but I may need to look at this again in the future.

    I did have a brief look into the < > but no joy. And, yes, the regex matched all the way to the image's >

    0
  • & lt; & gt; !

    0

Recent Posts

in Pipes