You are here: Transaction Rules > Transaction Elements > Fields Element > Java Regular Expressions for Masks

Java Regular Expressions for Masks

Masks are defined using Java Regular Expressions. The internet provides many tutorials on the use of regular expressions. A regular expression tester is available at http://www.regular-expressions.info/javascriptexample.html and can be used to test the regular expressions configured for masks.

Below are several examples of regular expressions used to define masks.

 

Mask Name Input Format Output Format User Input Masked Output
Password (\w{3}) ($1)*** ppp (ppp)***
PhoneNumber (\d{3})(\d{3})(\d{4}) 0 91 ($1) $2 $3 1112223333 0 91 (111) 222 3333
USPhoneNumber (\d{3})(\d{3})(\d{4}) ($1)-($2)-($3) 1112223333 (111)-(222)-(3333)
USPhoneNumber2 (\d{3})(\d{3})(\d{4}) ($3)-($2)-($3) 1112223333 (3333)-(222)-(3333)
USPhoneNumber 3 (\d{3})(\d{3})(\d{4}) *$2* 1112223333 *222*

 

Input expressions serve two purposes:

  1. Provide validation pattern for the user input.
  2. Provide character groupings that are used for replacement/formatting in the output.

Output expressions format and/or perform string replacement according to the groupings indicated by the input expression. Groups are formed by using () in the input expression. The captured groups are represented by $1, $2, and so forth. These groups can be used in any combination/permutation to obtain the required output.

Copyright © 2009, 2011, Oracle and/or its affiliates. All rights reserved. Legal Notices