The following table shows example uses of regular expressions. All examples work for REGEXP and some also work for SIMILAR TO, as noted in the Example column. Results vary depending on the search condition you use for searching. For those that work with SIMILAR TO, results can vary further depending on case and accent sensitivity.
Note that backslashes should be doubled if the examples are used in literal strings (for example, '.+@.+\\..+'
)
Example | Sample matches | ||||||||
---|---|---|---|---|---|---|---|---|---|
Credit Card Numbers (REGEXP only): Visa:
MasterCard:
American Express:
Discover:
|
Matches (Visa): 4123 6453 2222 1746 Non-Matches (Visa): 3124 5675 4400 4567, 4123-6453-2222-1746 Similarly, MasterCard matches a set of 16 numbers, starting with 5, with a space between each subset of four numbers. American Express and Discover are the same, but must start with 37 and 6011 respectively. |
||||||||
Dates (REGEXP and SIMILAR TO):
|
Matches: 31/04/1999, 15/12/4567 Non-Matches: 31/4/1999, 31/4/99, 1999/04/19, 42/67/25456 |
||||||||
Windows absolute paths (REGEXP only):
|
Matches: \\server\share\file Non-Matches: \directory\directory2, /directory2 |
||||||||
Email Addresses (REGEXP only):
|
Matches: abc.123@def456.com, _123@abc.ca Non-Matches: abc@dummy, ab*cd@efg.hijkl |
||||||||
Email Addresses (REGEXP only):
|
Matches: *@qrstuv@wxyz.12345.com, __1234^%@@abc.def.ghijkl Non-Matches: abc.123.*&ca, ^%abcdefg123 |
||||||||
HTML Hexadecimal Color Codes (REGEXP and SIMILAR TO):
|
Matches: AB1234, CCCCCC, 12AF3B Non-Matches: 123G45, 12-44-CC |
||||||||
HTML Hexadecimal Color Codes (REGEXP only):
|
Matches: AB 11 00, CC 12 D3 Non-Matches: SS AB CD, AA BB CC DD, 1223AB |
||||||||
IP Addresses (REGEXP only):
|
Matches: 10.25.101.216 Non-Matches: 0.0.0, 256.89.457.02 |
||||||||
Java Comments (REGEXP only):
|
Matches Java comments that are between /* and */, or one line comments prefaced by //. Non-Matches: a=1 |
||||||||
Money (REGEXP only):
|
Matches: $1.00, -$97.65 Non-Matches: $1, 1.00$, $-75.17 |
||||||||
Positive, negative numbers, and decimal values (REGEXP only):
|
Matches: +41, -412, 2, 7968412, 41, +41.1, -3.141592653 Non-Matches: ++41, 41.1.19, -+97.14 |
||||||||
Passwords (REGEXP and SIMILAR TO):
|
Matches: abcd, 1234, A1b2C3d4, 1a2B3 Non-Matches: abc, *ab12, abcdefghijkl |
||||||||
Passwords (REGEXP only):
|
Matches: AB_cd, A1_b2c3, a123_ Non-Matches: *&^g, abc, 1bcd |
||||||||
Phone Numbers (REGEXP and SIMILAR TO):
|
Matches: 519-883-6898, 519 888 6898 Non-Matches: 888 6898, 5198886898, 519 883-6898 |
||||||||
Sentences (REGEXP only):
|
Matches: Hello, how are you? Non-Matches: i am fine |
||||||||
Sentences (REGEXP only):
|
Matches: Hello, how are you? Non-Matches: i am fine |
||||||||
Social Security Numbers (REGEXP and SIMILAR TO):
|
Matches: 123-45-6789 Non-Matches:123 45 6789, 123456789, 1234-56-7891 |
||||||||
URLs (REGEXP only):
|
Matches: http://www.sample.com, www.sample.com Non-Matches: http://sample.com, http://www.sample.comm |
Discuss this page in DocCommentXchange.
|
Copyright © 2012, iAnywhere Solutions, Inc. - SQL Anywhere 12.0.1 |