Replace by Regular Expression

Replace by Regular Expression

Logic name

Replace by Regular Expression (Document Mapper/Variable Mapper/Merge Mapper)

Function

This logic replaces the input string using regular expressions and returns the result.

Data types

Location

Type

First input handler

String

Logic output

String

= Hint =

Refer to the following for details:

Properties

Category

Property

Description

Required settings

String before replacement (regular expression pattern)

Specify the pattern of string to replace.

Required settings

String after replacement

Specify the string to replace with.

Comment

Comment

You can write a description of the logic. It doesn't affect the conversion process.

Function details

Regular expression pattern

The available regular expression patterns conform to java.util.regex.Pattern.

= Remarks =

For more details on Pattern, refer to "Java(TM) Platform, Standard Edition 8 API Specification" (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 the replaceAll() method of the java.lang.String class.

As a result, a dollar sign ($) may be treated as a reference to a forward-referenced 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

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

= Remarks =

For details on the 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 codes to "*".

Property settings

Properties

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)

Output data

Sample A(***-***)

Sample B(***-***)

Sample C(***-***)

 

= Hint =

For a list of logics, refer to Mapper Logic Guide.