ReplaceTextMatchPattern2 Function

Number of input and output field

Number of input field : One
Number of output field : One


This transformation function is used to replace a portion of the input text with another text, where both the replaced text and the replacement text are defined using regular expression patterns found in the input.

The parameters of this function are:

Example
      input text : (12345)
   Using parameter 
      Target Pattern Expression         = \\(\\d\\d\\d+\\)
      Replacement Pattern Expression    = \\d\\d\\d+
      output text : 12345
    
   Using parameter 
      Target Pattern Expression         = \\(\\d\\d\\d+\\)
      Replacement Pattern Expression    = -%\\d\\d\\d+%
      output text : -12345
    
   Using parameter 
      Target Pattern Expression         = \\(\\d\\d\\d+\\)
      Replacement Pattern Expression    = abc%\\d\\d\\d+%xyz
      output text : abc12345xyz

Here under are tables used in Regular Expression


Table 1 : Character representations
Sequence Meaning
\a Alert (bell).
\b Backspace, \x08, supported only in character class.
\e Esc character, \x1B.
\n Newline, \x0A.
\r Carriage return, \x0D.
\f Form feed, \x0C.
\t Horizontal tab, \x09.
\0octal Character specified by a one-, two-, or three-digit octal
\xhex Character specified by a two-digit hexadecimal code.
\uhex Unicode character specified by a four-digit hexadecimal code.
\cchar Named control character.

Table 2 : Character classes and class-like constructs .
Class Meaning
[...] A single character listed or contained in a listed range.
[^...] A single character not liste and not contained within a listed range.
. Any character, except a line terminator (unless DOTALL mode).
\w Word character,[a-zA-Z0-9_].
\W Nonword character,[^a-zA-Z0-9_].
\d Digit,[0-9].
\D Nondigit,[^0-9].
\s Whitespace character,[ \t\n\f\r\x0B].
\S Nonwhitespace character,[^ \t\n\f\r\x0B].
\p{prop} Character contained by given POSIX character class, Unicode property, or Unicode block.
\P{prop} Character not contained by given POSIX character class,Unicode property, or Unicode block.

Table 3 : Anchors and other zero-width tests.
Sequence Meaning
^ Start of string, or the point after any newline if in MULTILINE mode.
\A Beginning of string, in any match mode.
$ End of string, or the point before any newline if in MULTILINE mode.
\Z End of string, but before any final line terminator, in any match mode.
\z End of string, in any match mode.
\b Word boundary.
\B Not-word-boundary.
\G Beginning of current search.
(?=...) Positive lookahead.
(?!...) Negative lookahead.
(?<=...) Positive lookbehind.
(? Negative lookbehind.

Table 4 : Comments and mode modifiers.
Modifier/sequence Mode character Meaning
Pattern.DOTALL s Dot (.) matches any character, including a line terminator.
Pattern.MULTILINE m ^ and $ match next to embedded line terminators.
Pattern.COMMENTS x Ignore whitespace, and allow embedded comments starting with #.
Pattern.CASE_INSENSITIVE i Case-insensitive match for ASCII characters.
Pattern.UNICODE_CASE u Case-insensitive match for Unicode characters.
Pattern.CANON_EQ Unicode 'canonical equivalence' mode, where characters, or sequences of a base character and combining characters with identical visual representations, are treated as equals.
(?mode) Turn listed modes(one or more of idmsux) on for the rest of the subexpression.
(?-mode) Turn listed modes(one or more of idmsux) off for the rest of the subexpression.
(?mode:...) Turn listed modes(one or more of idmsux) on within parentheses.
(?-mode:...) Turn listed modes(one or more of idmsux) off within parentheses.
#... Treat rest of line as a comment in /xmode

Table 5 : Grouping, capturing, conditional,and control.
Sequence Meaning
(...) Group subpattern and capture submatch into\1,\2,...and $1,$2,....
\n Contains text matched by thenth capture group. $n In a replacement string, contains text matched by the nth capture group.
(?:...) Groups subpattern, but does not capture submatch.
(?>...) Atomic grouping.
...|... Try subpatterns in alternation.
* Match 0 or more times.
+ Match 1 or more times.
? Match 1 or 0 times.
{n} Match exactlyntimes.
{n,} Match at leastntimes.
{x,y} Match at leastxtimes, but no more thanytimes.
*? Match 0 or more times, but as few times as possible.
+? Match 1 or more times, but as few times as possible.
?? Match 0 or 1 times, but as few times as possible.
{n,}? Match at leastntimes, but as few times as possible.
{x,y}? Match at leastxtimes, no more thanytimes, and as few times as possible.
*+ Match 0 or more times, and never backtrack.
++ Match 1 or more times, and never backtrack.
?+ Match 0 or 1 times, and never backtrack.
{n}+ Match at leastntimes, and never backtrack.
{n,}+ Match at leastntimes, and never backtrack.
{x,y}+ Match at leastxtimes, no more thanytimes, and never backtrack


Notes:
\ is used as for escape sequence in many programming languages, including Java.
Printing a \ or " which are special in string literal you have to escape it with another \ which gives us \\ and \"