YahooPipesRegex |
Immutable Page | Raw Text | Print View | History
FrontPage > YahooPipes > YahooPipesRegex Regular Expressions in Yahoo PipesThe basicsThe RegEx? module is one of the most powerful modules in Yahoo Pipes. You can do all kind of data transformations with it. This wiki page here would like to give you a short overview. Please note: Like in the Yahoo Pipes discussions, I put RegEx? patterns within square brackets. That way, you can distinguish for example [] and [ ] easily. Please omit the square brackets unless noted otherwise. The ModifiersYou might have noticed four checkboxes next to each RegEx? line. Those are used for modifying the way the RegEx? behaves and succeeded the so called "embedded pattern-match modifiers". But they did not completely replace them. In fact, you can use the modifiers "I, M, S and X" in embedded notation, while the checkboxes offer the options "I, M, S and G". So there's no X for checkboxes while there's no G for the embedded notification. The answer is taken from the Yahoo Pipes Discussions and updated with information from RegEx documentation started. What they do
Embedded Notation Hapdaniel from the Yahoo Pipes Discussions points out, the original form of specifying those flags is the "embedded notation". If you prefix your RegEx? with a (?x), you'll set the X-modificator. You cannot set a (?g) that way, though. Checkbox Notation To activate one of the checkbox-flags, just tick it. You can tick as many flags as you like. Except the X-flag, which apparently is not available as checkbox. Common patternsMatching empty What, if you want to match "nothing"? Hapdaniel has the solution:
Matching not empty And here's the opposite, again from the suggestion thread.
Removing whitespace Sometimes, you'd like to remove all the linefeeds and unwanted spaces out of a field. I usually use a three- to fourfold approach to that. For each of the following replacements, use +g (the global flag)
With 1 and 2, you remove all hard linefeeds. With 3, you remove all "logical" linefeeds (the ones that only get rendered, when the field is interpreted as html). with 4, you make the result more compact. If for example you have 3 or more spaces in a row, those will be reduced to just one space. Using reserved characters In RegEx?, some characters are "reserved". That means, they are not used literally, but instead used as functions. Examples:
To "escape" reserved characters, that is to match them literally, you put a backslash in front. For example, matching (twitter) is possible by using \(twitter\). Removing html tags From a post in the Yahoo Pipes Discussion.
Showing Images From a post in the Yahoo Pipes Discussion. Sometimes, one of your field contains just an image URL. You'd like to replace that URL with an image tag, so it is rendered as an image.
Prefixing something Sometimes, you'd like to add something in front of a field. For example, to add a "Yahoo: " in front of every title, you could
$1 matches the first group used (we have only one group in this example). And ^ matches the beginning of the expression. Source: documentation started Postfixing something And to suffix something, you'd use a $ instead of the ^.
Source: RegEx documentation started Translating dates What, if you want to change a date of format mm/dd/yy to the ISO equivalent of yyyy-mm-dd ? You could use an expression like this one:
Here, we have three groups. In the result, I also prefix a "20" as the year was specified only with two digits. Convert to Uppercase Also from a Yahoo Pipes Discussion. You can use the \U flag to convert something to uppercase. For example
Convert to Lowercase No surprise here, you can use the \L flag to convert something to lowercase
|