RegEx Replace searches for all matches that match the given pattern and replaces those by a user given replacement text.
Basically just as the word functionality "find and replace". You can either search for a known or unknown expression and, in the case of the latter, define the pattern of the expression using our wizard.
Known Pattern
Step 1: Pattern configuration
- First you have to decide whether you want to provide a static keyword or search for the value of a variable.
- Secondly, you have to provide the necessary input (either the keyword itself or a variable containing the keyword).
- Under Configuration you can select the
following check boxes:
- Stand alone expression search: Your search is restricted to keywords that are located between word and non-word characters (e. g. a space or a colon). This might be helpful if you want to assure that you will only match a substring which consists of word characters and is enclosed by spaces (or any other non-word character). Instances where your pattern is enclosed by other word characters would not result in a match.
- Case sensitive enabled: Differentiation between lower-case and upper-case letters (e. g. matches if pattern is "Test: word" and string is "Test: word". This would not be the case if the string is "test: word").
Step 2: Define replacement
- First you have to decide whether you want to provide a static replacement text or if you want to use a variable (in our example we selected the first option).
- Secondly, you have to provide the necessary input (either the replacement text itself or a variable containing the replacement text; in our example we provided the text "Test: failed"). You can either select a existing variable or create a new one by typing its name in the text field.
Step 3: Test pattern on example test
- Type your example test into the text-box (here: "Test: passed").
- Click Test.
- The replacement text field will show you the complete replaced string (in our example "Test: failed").
Unknown Pattern
Step 1: Pattern configuration
- Select the type of the pattern you want to
search for (Word, Text, Number, Integer, EmailAddress or TelephoneNumber).
- Word: Matches one or more word characters (e. g. "my" and "life" in "my life" but not "l.i.f.e" in "my l.i.f.e").
- Text: Matches any character (except a new line) zero or more times.
- Number: Matches any positive or negative number with "." or "," as thousand/decimal separator (e. g. "1.787", "-1,000.00", "1").
- Integer: Matches any positive or negative whole number (e. g. "10", "-23" but not "2.2", "1,000").
- EmailAddress: Matches all common email addresses with an @-sign in between and .xx, .xxx, .xxxx at the end (e. g. mailto:myemail@cmail.com but not "myemailcmail", "myemail@cmail.c").
- TelephoneNumber: Matches one or more digits including the characters "+", "*", "#", "(", ")" and "-" (e. g. "+49 (0)170 8976768" but not "1,700,000.00€").
- Specify the position at which you expect your
pattern to appear
- After: You expect that your pattern appears after a given substring and you type this substring into the text-box next to After (e. g. if string = "[…] Your Email: max.mustermann@anothermonday.com […]" you would check the box After and enter "Your Email: " into the text-box)
- Before: You expect that your pattern appears before a given substring and you type this substring into the text-box next to Before (e. g. if string = "[…] 78988776 (customer number) […]" then you would check the box Before and enter " (customer number)" in the text-box)
- You can provide a minimal or/and maximal length of the pattern you are searching for. This length does not include any characters that appear after or before the pattern.
- Under Configurations you can select one or both
of the following check boxes:
- Stand alone expression search: Your search is restricted to patterns that are located between word and non-word characters (e. g. a space or a colon). This might be helpful if you want to assure that you will only match a substring which consists of word characters and is enclosed by spaces (or any other non-word character). Instances where your pattern is enclosed by other word characters would not result in a match (e. g. matches if pattern is "(c\w+)" and stand alone expression search is checked: "My cat cannot be replaced by a dog." However, when you leave it unchecked the result will change: "My cat cannot be replaced by a dog.").
- Case sensitive enabled: Differentiation between lower-case and upper-case letters (e. g. matches if pattern is "Test: \s*(\w+)" and string is "Test: word". This would not be the case if the string is "test: word").
- The Pattern text-box shows you the Regex pattern that has been created as a result of your selection. If your pattern needs adjustment, this is the place to customize your pattern even further.
Step 2: Define replacement
- First you have to decide whether you want to provide a static replacement text or if you want to use a variable (in our example we selected the first option).
- Second you have to provide the necessary input (either the replacement text itself or a variable containing the replacement text; in our example we provided the text "Test: failed"). You can either select a existing variable or create a new one by typing its name in the text field.
Step 3: Test pattern on example test
- Type your example test into the text-box (here: "Test: passed").
- Click Test.
- The replacement text field will show you the complete replaced string (in our example "Test: failed").