PPA Tools: Regex
Summary
This module contains actions for searching & modifying text using regular expressions.
Actions
ppa_tools.regex.
replace
Replace a string with another inside some text using a regular expression.
Minimum Plugin Version: 5.6.0
Input
-
text: the text to process
-
expression: a regular expression that describes the text to replace
-
replacement: a string to replace any expression matches with
No Matches
This action will succeed and return the original text if no expression matches are found.
Output
A new copy of text with any replacements made.
Example
Removing all lines that end with - England:
- ppa_tools.regex.replace:
expression: >
.*\-\sEngland\n
replacement: ""
text: >
London - England
Manchester - England
Paris - France
New York - USA
save: replaced
The output will be:
Paris - France
New York - USA