User Tools

Site Tools


regular_expression_reference

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
regular_expression_reference [2009/01/14 03:54] stephenregular_expression_reference [2017/01/01 20:05] (current) – external edit 127.0.0.1
Line 1: Line 1:
 +====== .NET Regular Expression Reference ======
 +
 +===== Favourite Regexs =====
 +
 +==== Email Address ====
 +
 +<code>
 +^([\w-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([\w-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$
 +</code>
 +
 +==== Log4Net Match Thread Id ====
 +
 +<code>
 +^\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2},\d{3} \[10\].*?$
 +</code>
 +
 +
 ===== Characters that Match Location in Strings ===== ===== Characters that Match Location in Strings =====
    
Line 36: Line 53:
 | {n} | The n is a non-negative integer. Matches exactly n times. For example, “o{2}” does not match the “o” in “Bob” but does match the two “o”s in “food”. | | {n} | The n is a non-negative integer. Matches exactly n times. For example, “o{2}” does not match the “o” in “Bob” but does match the two “o”s in “food”. |
 | {n,} | The n is a non-negative integer. Matches at least n times. For example, “o{2,}” does not match the “o” in “Bob” and does match all the “o”s in “foooood”. The sequence “o{1,}” is equivalent to “o+”. The sequence “o{0,}” is equivalent to “o*”. | | {n,} | The n is a non-negative integer. Matches at least n times. For example, “o{2,}” does not match the “o” in “Bob” and does match all the “o”s in “foooood”. The sequence “o{1,}” is equivalent to “o+”. The sequence “o{0,}” is equivalent to “o*”. |
-| {n,m} | The m and n are non-negative integers, where “n <= m”. Matches at least n and at most m times. For example, “o{1,3}” matches the first three “o”s in “fooooood”. “o{0,1}” is equivalent to “o?”. Note that you cannot put a space between the comma and the numbers. |+| {n,m} | The m and n are non-negative integers, where “n ≤ m”. Matches at least n and at most m times. For example, “o{1,3}” matches the first three “o”s in “fooooood”. “o{0,1}” is equivalent to “o?”. Note that you cannot put a space between the comma and the numbers. |
 | ? | When this character immediately follows any of the other quantifiers (*, +, ?, {n}, {n,}, {n,m}), the matching pattern is non-greedy. A non-greedy pattern matches as little of the searched string as possible, whereas the default greedy pattern matches as much of the searched string as possible. For example, in the string “oooo”, “o+?” matches a single “o”, whereas “o+” matches all “o”s. | | ? | When this character immediately follows any of the other quantifiers (*, +, ?, {n}, {n,}, {n,m}), the matching pattern is non-greedy. A non-greedy pattern matches as little of the searched string as possible, whereas the default greedy pattern matches as much of the searched string as possible. For example, in the string “oooo”, “o+?” matches a single “o”, whereas “o+” matches all “o”s. |
 | . | Matches any single character except “\n”. To match any character including the “\n”, use a pattern such as “[\s\S]”. | | . | Matches any single character except “\n”. To match any character including the “\n”, use a pattern such as “[\s\S]”. |
Line 52: Line 69:
 | \W | Matches any non-word character. Equivalent to “''[^A-Za-z0-9_]''”. | | \W | Matches any non-word character. Equivalent to “''[^A-Za-z0-9_]''”. |
  
-{{tag>reference regex}}+{{tag>reference regex dot_net}}
regular_expression_reference.1231905266.txt.gz · Last modified: 2017/01/01 19:51 (external edit)

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki