I’m currently working on a pipe on Yahoo! Pipes. I got a RegExp to match an URL. Now, I need to match the unmatched in order to delete it, so that there is only my URL. My RegExp is:
[A-Za-z]+:\/\/[A-Za-z0-9-_]+\.[A-Za-z0-9-_:%&\?\/.=]+
How do I invert the matching? (It has to be done via another RegExp, YPipes doesn’t support any other way.)
edit: For clarification: I got a string and need to get the first URL inside of it. That’s why nothing else works…
Yahoo Pipes supports regex replace (use a String Regex module).
Then match the part you want to keep and capture it in a group. You are already doing this, although your regex itself is slightly wrong, here is one that at least has the obvious errors corrected:
and then replace the entire string with the contents of that group. Just put
$1into the “replace with” field. Effectively this removes everything you did not want to keep.Since I am not sure what your regex should actually do, I can’t give you a better version.
As a general hint: Regex is always and only about matching stuff, and never ever about not matching (i.e. “excluding”) stuff. There are regexes that have an excluding effect, but even they achieve it through matching.