Displaying page
of
pages;
Items to
Title |
Test
Details
Pattern Title
|
Expression |
\w?<\s?\/?[^\s>]+(\s+[^"'=]+(=("[^"]*")|('[^\']*')|([^\s"'>]*))?)*\s*\/?>
|
Description |
Matches tags
|
Matches |
<world www="hello" />
|
Non-Matches |
<>>>world www="hello" />
|
Author |
Rating:
Not yet rated.
Darren Neimke
|
Title |
Test
Details
Pattern Title
|
Expression |
"([^"](?:\\.|[^\\"]*)*)"
|
Description |
Matches C style strings allowing for escaped string delimiters to be included in the match.
ALTERED 13-Dec-2003
-------------------
Previous pattern was :
"([^"](?:\\.|[^\\"]*)*)"
Changed to:
"([^"]*(?:\\.|[^\\"]*)*)"
Making the first character after the opening quote optional allows the pattern to match on empty quotes: "".
|
Matches |
"This is a \"string\"."
|
Non-Matches |
"This is a \"string\".
|
Author |
Rating:
Darren Neimke
|
Title |
Test
Details
Pattern Title
|
Expression |
(\w[-._\w]*\w@\w[-._\w]*\w\.\w{2,3})
|
Description |
This is my all-time favourite e-mail validator. I've used it for years and it's never failed me :-)
|
Matches |
|
Non-Matches |
|
Author |
Rating:
Darren Neimke
|
Title |
Test
Details
Pattern Title
|
Expression |
^([a-zA-Z]\:)(\\[^\\/:*?<>"|]*(?<![ ]))*(\.[a-zA-Z]{2,6})$
|
Description |
Matches filenames.
UPDATED on 1st Jan 2004.
|
Matches |
C:\di___r\fi_sysle.txt | c:\dir\filename.txt
|
Non-Matches |
c:\dir\file?name.txt
|
Author |
Rating:
Not yet rated.
Darren Neimke
|
Title |
Test
Details
Pattern Title
|
Expression |
(\b\w+\b) # Match a word and capture it
\s+
\1 # Use backreference \1 to match double-ups
|
Description |
|
Matches |
This is is a match
|
Non-Matches |
This isn't!
|
Author |
Rating:
Not yet rated.
Darren Neimke
|
Title |
Test
Details
Pattern Title
|
Expression |
(?'openingTag'<)
\s*?
(?'tagName'\w+)
# Once we've got the tagname, match zero
# or more attribute sequences
(\s*?
# Atomic Grouping for efficiency
(?>
(?!=[\/\?]?>) # Lookahead so that we can fail quickly
# match Attribute pieces
(?'attribName'\w+)
(?:\s*
(?'attribSign'=)
\s*
)
(?'attribValue'
(?:\'[^\']*\'|\"[^\"]*\"|[^ >]+)
)
)
)*
\s*?
# Closing Tag can be either > or />
(?'closeTag'[\/\?]?>)
|
Description |
Matches and segments the sections of an opening tag. For more detailed information refer to this blog entry: http://weblogs.asp.net/dneimke/posts/25616.aspx
|
Matches |
<head> | <script language=javascript> | <input type=submit >
|
Non-Matches |
</head>
|
Author |
Rating:
Not yet rated.
Darren Neimke
|
Title |
Test
Details
Pattern Title
|
Expression |
# Greedy, no-backtracking and only named groups capture.
(?n)
^
(
(?'allowDay'Sun|Mon|Fri)
|
(Sat
# if we match 'ur' then constrain
# the next char with a lookahead
# for 'd' so that we don't match on
# Satur.
(?'allowDay'ur(?=d))?
)
|
(
(
(
T
(
# Accepts "Tu.", "Tue."
ue?
|
# Accepts "Th.", "Thu." or "Thur."
h(ur?)?
)
)
|
(
Wed
# if "ne" matched then constrain
# the next chars with a lookahead
# for 'sd' so that we don't match on
# Wedne.
(ne(?=sd))?
)
)
(
# If 'Tue' or 'Thur' or 'Wedne' matched
# then match 's' in the "allowDay" Group.
(?<=(e|r))
(?'allowDay's)
)?
)
)
# Optional ending match of "day" or "."
(
# if Group[allowDay] succeeded then allow
# the letters "day" or a full-stop. If it
# did not succeed, a full-stop is required.
(?(allowDay)day)|\.
)?
$
|
Description |
|
Matches |
Th | Thu | Thurs
|
Non-Matches |
Thursd | T | Thursdays
|
Author |
Rating:
Darren Neimke
|
Title |
Test
Details
Pattern Title
|
Expression |
(\d{4,6})
|
Description |
Simple Postcode - this is the first test of the new WebService :-)
|
Matches |
4078 | 539999
|
Non-Matches |
dfasdf | afasdfsad
|
Author |
Rating:
Not yet rated.
Darren Neimke
|
Title |
Test
Details
Pattern Title
|
Expression |
^(\d+|[a-zA-Z]+)$
|
Description |
Tests for all numbers OR all letters (upper or lower case)
( posted from WebService - http://regexlib.com/webservices.asmx?op=Save )
( updated from WebService - http://regexlib.com/webservices.asmx?op=Save )
|
Matches |
aaaaadddaaaaa | 1166633337
|
Non-Matches |
1n | ppppp99
|
Author |
Rating:
Not yet rated.
Darren Neimke
|
Title |
Test
Details
Pattern Title
|
Expression |
(?s)/\*.*\*/
|
Description |
|
Matches |
/* .................... */ | /* imagine lots of lines here */
|
Non-Matches |
*/ malformed opening tag */ | /* malformed closing tag /*
|
Author |
Rating:
Not yet rated.
Darren Neimke
|
Title |
Test
Details
Pattern Title
|
Expression |
.*?$(?<!\.aspx)
|
Description |
Matches a string to ensure that it does not end with .aspx; sure, you'd probably use string handling to do something this simple but, in the real world you'd whack a regex which validates a valid url to the front of this.
The pattern was created by Wayne King; you can read about it here:
http://scottwater.com/blog/posts/10204.aspx
|
Matches |
http://weblogs.asp.net/DNeimke/blah.gif
|
Non-Matches |
http://weblogs.asp.net/DNeimke/Default.aspx
|
Author |
Rating:
Not yet rated.
Darren Neimke
|
Title |
Test
Details
Pattern Title
|
Expression |
^ISBN\s(?=[-0-9xX ]{13}$)(?:[0-9]+[- ]){3}[0-9]*[xX0-9]$
|
Description |
This pattern validates ISBN numbers. I've written a full description about it here: http://regexblogs.com/dneimke/posts/201.aspx
|
Matches |
ISBN 90-70002-34-5 | ISBN 90-70002-34-x
|
Non-Matches |
ISBN 90-70002-34-5x | ISBN 90-700-02-34-5
|
Author |
Rating:
Not yet rated.
Darren Neimke
|
Title |
Test
Details
Pattern Title
|
Expression |
(?<=^|[\s ]+)[^\!\@\%\$\s ]*([\!\@\%\$][^\!\@\%\$\s ]*){2,}(?=[\s ]+|$)
|
Description |
That pattern will filter for words that contain more than 1 instance of any of the following characters: ! $ % @.
May be useful in filtering for spam.
Requires lookahead and lookbehind support in the underlying regex engine.
|
Matches |
f%c$ | v!@gra | v@gr@
|
Non-Matches |
f%ck | viagra
|
Author |
Rating:
Not yet rated.
Darren Neimke
|
Title |
Test
Details
Pattern Title
|
Expression |
(?n) (?# ExplicitCapture - capture named groups only )
^
-? (?# Optional sign )
(
\d{1,8}(\.\d{1,2})? (?# Decimal point and trailing digits optional )
|
\d{0,8}(\.\d{1,2}) (?# Leading digits optional )
)
$
|
Description |
This pattern matches a simple Decimal Literal. Leading digits limited to 8 and does not support commification.
|
Matches |
-14 | -14.26 | -.26
|
Non-Matches |
-14. | -14.263 | -
|
Author |
Rating:
Not yet rated.
Darren Neimke
|
Title |
Test
Details
Pattern Title
|
Expression |
(?'DateLiteral' (?# Per the VB Spec : DateLiteral ::= '#' [ Whitespace+ ] DateOrTime [ Whitespace+ ] '#' )
\#\s*
(?'DateOrTime' (?# DateOrTime ::= DateValue Whitespace+ TimeValue | DateValue | TimeValue )
(?'DateValue'
(?# DateValue ::= Whitespace+ TimeValue | DateValue | TimeValue )
(
(?# DateValue ::= MonthValue / DayValue / YearValue | MonthValue - DayValue - YearValue )
(?'Month'(0?[1-9])|1[0-2]) (?# Month 01 - 12 )
(?'Sep'[-/]) (?# Date separator '-' or '/' )
(?'Day'0?[1-9]|[12]\d|3[01]) (?# Day 01 - 31 )
\k'Sep' (?# whatever date separator was previously matched )
(?'Year'\d{1,4})
\s+
(?# TimeValue ::= HourValue : MinuteValue [ : SecondValue ] [ WhiteSpace+ ] [ AMPM ] )
(?'HourValue'(0?[1-9])|1[0-9]|2[0-4]) (?# Hour 01 - 24 )
[:]
(?'MinuteValue'0?[1-9]|[1-5]\d|60) (?# Minute 01 - 60 )
[:]
(?'SecondValue':0?[1-9]|[1-5]\d|60)? (?# Optional Minute :01 - :60 )
\s*
(?'AMPM'[AP]M)?
)
|
(
(?# DateValue ::= MonthValue / DayValue / YearValue | MonthValue - DayValue - YearValue )
(?'Month'(0?[1-9])|1[0-2]) (?# Month 01 - 12 )
(?'Sep'[-/]) (?# Date separator '-' or '/' )
(?'Day'0?[1-9]|[12]\d|3[01]) (?# Month 01 - 31 )
\k'Sep' (?# whatever date separator was previously matched )
(?'Year'\d{4})
)
|
(
(?# TimeValue ::= HourValue : MinuteValue [ : SecondValue ] [ WhiteSpace+ ] [ AMPM ] )
(?'HourValue'(0?[1-9])|1[0-9]|2[0-4]) (?# Hour 01 - 24 )
[:]
(?'MinuteValue'0?[1-9]|[1-5]\d|60) (?# Minute 01 - 60 )
[:]
(?'SecondValue':0?[1-9]|[1-5]\d|60)? (?# Optional Minute :01 - :60 )
\s*
(?'AMPM'[AP]M)?
)
)
)
\s*\#
)
|
Description |
Match the VB Language specification BNF for DateTime literal. http://msdn.microsoft.com/library/en-us/vbls7/html/vblrfvbspec2_4_6.asp?frame=true
DateLiteral ::= # [ Whitespace+ ] DateOrTime [ Whitespace+ ] #
DateOrTime ::=
DateValue Whitespace+ TimeValue |
DateValue |
TimeValue
DateValue ::=
MonthValue / DayValue / YearValue |
MonthValue – DayValue - YearValue
TimeValue ::=
HourValue : MinuteValue [ : SecondValue ] [ WhiteSpace+ ] [ AMPM ]
MonthValue ::= IntLiteral
DayValue ::= IntLiteral
YearValue ::= IntLiteral
HourValue ::= IntLiteral
MinuteValue ::= IntLiteral
SecondValue ::= IntLiteral
AMPM ::= AM | PM
|
Matches |
# 8/23/1970 3:45:39AM # | # 8/23/1970 #
|
Non-Matches |
## | # 23/8/1970 #
|
Author |
Rating:
Darren Neimke
|
Title |
Test
Details
Pattern Title
|
Expression |
^(
100(?:\.0{1,2})?
|
0*?\.\d{1,2}
|
\d{1,2}(?:\.\d{1,2})?
)%
$
|
Description |
Matches a percentage between 0 and 100 (inclusive). Accepts up to 2 decimal places.
|
Matches |
0% | 100% | .17%
|
Non-Matches |
101% | -17 | 99.006%
|
Author |
Rating:
Not yet rated.
Darren Neimke
|
Displaying page
of
pages;
Items to