What are some sample recognizer Java regular expressions?
Some sample recognizers for Widgets and Live Text are shown below using a Java regular expression (reg ex).
Sample 1
A sample US zip code regular expression is shown.
- Recognizer name
- US Zip Code
- Regular expression (reg ex)
- \b[0-9]{5}\b
- Description
- Any five digit number with word breaks around it
- Example
- 01886
- Group 0
- 01886
Sample 2
A sample stock exchange regular expression is shown.
- Recognizer name
- Exchange Stock Symbol
- Regular expression (reg ex)
- (NYSE|AMEX|NASDAQ):([A-Z]{1,4})
- Description
- Any of these exchanges followed by a colon, followed by an uppercase symbol
- Example
- NYSE:IBM
- Group 0
- NYSE:IBM
- Group 1
- NYSE
- Group 2
- IBM®
Sample 3
A sample US currency regular expression is shown.
- Recognizer name
- US Currency Recognizer
- Regular expression (reg ex)
- \$(\d*)(\.\d{2})?
- Description
- A dollar sign, followed by any amount of numbers and, optionally, a period followed by two digits
- Example
- $215.95
- Group 0
- $215.95
- Group 1
- 215
- Group 2
- .95
For a list of Java regular expressions and tools, reference the following sites:
java.sun.com/j2se/1.5.0/docs/api/java/util/regex/Pattern.html
regex.powertoy.org