.NET & JavaScript Regular Expression Tester
Pattern: l.*?y
.NET
10 matches
|
|
Position
|
Match
|
| 36 | lazy |
| 48 | Lazy |
| 103 | lazy |
| 120 | lazy |
| 175 | lazy |
| 196 | lazy |
| 251 | lazy |
| 263 | lazy |
| 329 | lazy |
| 346 | lazy |
|
JavaScript
|
|
Position
|
Match
|
|
|
Regular expressions are used to identify specific patterns within text. They are useful
for validating the format of email address, phone numbers, social security numbers,
and other text with distinctive patterns. They are also useful for finding, replacing
and extracting text.
Regular expressions allow patterns to be described in an abstract format. For example, the pattern
"j\w*" will find all works starting with "j", followed by zero or more (*) words characters
[a-zA-Z_0-9]. The pattern for a 5 digit number such as a zip code is "\d{5}" where "\d" represents
any digits and {5} is the quantity.
The interpretion of regular expressions can differ depending upon the programming language or
framework used. The tester above uses both Microsoft's .NET (server-side) and JavaScript (client-side).
|
Pattern
|
Finds
|
|
lazy
|
All instances of the word "lazy"
|
|
l.*?y |
All words starting with "l" and ending with "y". The "." represents
any single character (except line breaks), the "*" means any quantity, and the "?" specifices
non-greedy search (end at first match).
|
|
\b[tTq]\w*\b |
All strings starting with "t", "T", or "q" (\b
matches word boundary, square brackets [] defines a set of characters of which one
must match, \w matches word characters: [a-zA-Z_0-9].
|
|
\b\w{3}\b |
All 3-letter words.
|
|
\d{3}-\d{4} |
All 7 digit phone numbers with a required dash after the third digit.
|
|
<.*?> |
All HTML tags. "." represents "any character," "*" is any quantity, ? is non-greedy search.
|
|
<(\w+>).+?</\1 |
Matching pairs of HTML tags using back references. The parenthesis () create a
subexpression that can be referenced later in the expression. The \1 refers back
to the first subexpression and requires matching text. For instance, if the
subexpression matched on "h3" then the back reference \1 must also contain "h3."
|
|
[\w!#$%*/?|\^\{\}'~\.]+@(\w+\.)*\w{2,3} |
All email addresses (this simplified expression will allow some invalid email formats).
|