Return regex match in Yahoo Pipes
-
27-06-2021 - |
Question
I want to take my 'item.title' string and store a match from a regular expression into 'item.myRegexMatch'. However, it's unclear to me how to achieve this, as all the Regex modules in YP require a "replacement" string. I don't want to replace anything; I just want the Regex match returned. This seems trivial, but I'm fairly new with YP and regular expressions, so hopefully I'm simply overlooking this basic functionality.
Solution
Quick answer :
Steps :
1/ Rename module :
[item.title] COPY [item.myRegexMatch]
2/ Regex module :
in [item.myRegexMatch] replace [^.*(YOURREGEX).*] with [$1]
^ ^
be sure to keep the 2 parentheses indicated in the above line.
Explaination :
The parentheses in the "replace" field define a backreference.
This backrefencere is then used ($1) in the "with" field.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow