The most basic building block in a regular expression is a character a.k.a. Most characters in a regex pattern do not have a special meaning, they simply match themselves.Consider the following pattern: None of the characters in this pattern carries special meaning. Therefore there is only one string that matches this pattern, and it is identical to the pattern string itself: “I am a harmless regex pattern”.
If it does, the input string is an element of the set of strings represented by that regex pattern. People solve real-world string processing problems using regex patterns leaving aside the abstract idea of a regex representing a “set of strings” and concentrating on the problem at hand. Regular expressions have inherent limitations every practitioner should be aware of.
The regular expression evaluation window allows to match regular expressions against up to three different input strings.
The input field for the test strings turns green if the regex matches the input field’s current value. The “Capture” section of the evaluation window is useful for testing data extraction from the input string.
Regex patterns are also often used to specify/filter file names.
This post explains the basics of regular expressions and provides samples for many PDI features that support them in the download package.
Suppose a string containing this notation should be validated and the components (the letter and the digit) extracted using capture groups. For another example, suppose a pattern should match all strings that consist of the letter “q” followed by four lower case vowels.
This pattern matches all 100 two digit strings (namely the range from “00″ to “99″).
There is also a good online Java regex tester, that is very similar in functionality.
It is very useful if you’d like to follow the examples in another browser window.
On an abstract level a regular expression, regex for short, is a representation of a set of strings. Instead of having a list and thus the complete set of strings that are valid zip codes, it’s often more practical to have a short and precise regex that completely describes the set. As an example consider the set of strings that end in “.csv”.
The following is a regular expression pattern that represents this set.
But grouping the alternatives into a separate expression has another advantage.