Replace by Regular Expression

Logic Name

Replace by Regular Expression

Function

Replaces the input string by regular expression and returns the result.

Data Types

Location Type
The first input handler String
Logic output String
lightbulbRefer to "Logic Specifications" for details.

Properties

Category Property Description
Required String before replacement(regular expression pattern) Specify the pattern of string to replace.
Required String after replacement Specify the string to replace with.
Comment Comment The comment will also be output to the specifications.It does not affect the conversion process.

Function Details

Regular expression pattern

The available regular expression pattern is in accordance with java.util.regex.Pattern class of Java.
For details, refer to "Java(TM) Platform, Standard Edition 8 API Specification"(the URL below).(http://docs.oracle.com/javase/8/docs/api/java/util/regex/Pattern.html)

Regular Expression Reference

Reference notation Meaning
^ Beginning of line
$ End of line
. Any single character except newline
[] Any single character enclosed with[]
[^] Any single character not enclosed with[]
* Repeats the previous character for 0 time or more.
+ Repeats the previous character for once or more.
? 0 or 1 of the previous character
{a} Repeats the previous character for exactly "a" times.
{a,} Repeats the previous character for "a" or more than "a" times.
{a,b} Repeats the previous character for "a" to "b" times.
| Alternative operator(OR)
\ Escape character

String after replacement

Replace by Regular Expression uses replaceAll() method of java.lang.String class.
As a result, a dollar sign ($) may be treated as a reference to a captured subsequence in a string after replacement, and a backslash (\) is used to escape a character in the string.
When you output a backslash or a dollar sign, escape it with a backslash.
String before replacement (regular expression pattern) String after replacement The first input handler Logic output
(\d{1,2}:\d{2}) PM $1 p.m. 9:00 PM 9:00 p.m.
(\d{1,2}:\d{2}) PM \$1 p.m. 9:00 PM $1 p.m.
c \* abcde ab*de
c \\* abcde ab\*de
For details on String.replaceAll() method, refer to “Java(TM) Platform, Standard Edition 8 API Specification” (http://docs.oracle.com/javase/8/docs/api/java/lang/String.html#replaceAll-java.lang.String-java.lang.String-).

Logic Sample

Mapping Definition

Logic Settings and Processing Result

The logic converts product code to "*".
Property Settings
Property Setting
String before replacement(regular expression pattern) [A-Z]{3}-[0-9]{3}
String after replacement ***-***
Input Data
Sample A(ACE-036)
Sample B(KMO-147)
Sample C(VXZ-258)
Result Data
Sample A(***-***)
Sample B(***-***)
Sample C(***-***)