regexyahoo-pipes

Regex in Yahoo Pipes: append only if match found


In Yahoo Pipes, I'm trying to append content to existing string, but only if a match is found in that string.

Specifically, I want to append "#Fracking" to the end of the line, but only if "Hydraulic Fracturing" is found in the item.title.

My regex is as follows (doesn't work): replace (?(Hydraulic Fracturing)(.*)) with $1 $#Fracking

What am I doing wrong? Does Yahoo Pipes not support conditional regex? I could not find an answer to that.

Thanks for any help!


Solution

  • If I understood correctly, you could do like this:

    It seems that in Yahoo Pipes the matched string can be back referenced with $0.

    Here, the .* in the front and back make the entire string match if it contains "Hydraulic Fracturing", and then replace the whole thing with itself, plus "#Fracking" appended. If the string doesn't contain "Hydraulic Fracturing" then there will be no replacement.