RegExLib.com - The first Regular Expression Library on the Web!

Please support RegExLib Sponsors

Sponsors

Advanced Search

Keywords

Category

Minimum Rating

Results per Page

Search Results: 130 regular expressions found.

Change page:   |    Displaying page 1 of 7 pages; Items 1 to 20
Title Test Details Pattern Title
Expression
/\*[\d\D]*?\*/
Description
If you need to extract or remove any /* */ sytle comments from any Java, JavaScript, C, C++, CSS, etc code you have this regular expression can help.
Matches
/* my comment */ | /* my multiline comment */ | /* my nested comment */
Non-Matches
*/ anything here /* | anything between 2 seperate comments | \* *\
Author Rating: The rating for this expression. Chris Craft
Title Test Details Pattern Title
Expression
(http|ftp|https):\/\/[\w\-_]+(\.[\w\-_]+)+([\w\-\.,@?^=%&:/~\+#]*[\w\-\@?^=%&/~\+#])?
Description
*CORRECTED: Again thanks for all the comments below. If you want to include internal domain as well change the partial code (\.[\w-_]+)+ to (\.[\w-_]+)? See the comments below* This is the regular expression I use to add links in my email program. It also ignores those suppose-to-be commas/periods/colons at the end of the URL, like this sentence "check out http://www.yahoo.com/." (the period will be ignored) Note that it requires some modification to match ones that dont start with http.
Matches
http://regxlib.com/Default.aspx | http://electronics.cnet.com/electronics/0-6342366-8-8994967-1.html
Non-Matches
www.yahoo.com
Author Rating: The rating for this expression. M H
Title Test Details Pattern Title
Expression
^([1-zA-Z0-1@.\s]{1,255})$
Description
A general string validation to insure no malicious code is being passed through user input. General enough too allow email address, names, address, passwords, so on. Disallows ‘,\*&$<> or other characters that could cause issues.
Matches
[email protected] | My Name | asdf12df
Non-Matches
‘,\*&$<> | 1001' string
Author Rating: Not yet rated. Paul Miller
Title Test Details Pattern Title
Expression
^(([0]?[1-9]|[1][0-2])[\/|\-|\.]([0-2]\d|[3][0-1]|[1-9])[\/|\-|\.]([2][0])?\d{2}\s+((([0][0-9]|[1][0-2]|[0-9])[\:|\-|\.]([0-5]\d)\s*([aApP][mM])?)|(([0-1][0-9]|[2][0-3]|[0-9])[\:|\-|\.]([0-5]\d))))$
Description
MM-DD-20YY HH:MM AP MM-DD-20YY H:MM AP MM-DD-20YY HH:MM MM-DD-20YY H:MM MM-DD-YY HH:MM AP MM-DD-YY H:MM AP MM-DD-YY HH:MM MM-DD-YY H:MM M-D-YY HH:MM AP M-D-YY H:MM AP M-D-YY HH:MM M-D-YY H:MM where - can be / or - or . where : can be : or - or . Definition: ^( ;Start of Line ([0]?[1-9]|[1][0-2]) ;00-09 or 10-12 or 1-9 [\/|\-|\.] ;/ or - or . ([0-2]\d|[3][0-1]|[1-9]) ;00-29 or 30-31 or 1-9 [\/|\-|\.] ;/ or - or . ([2][0])?\d{2} ;2000-2099 or 00-99 \s+ ;one or more spaces ( ;must be either 12H notation w/AM|PM ( ([0][0-9]|[1][0-2]|[0-9]) [\:|\-|\.] ;: or - or . ([0-5]\d) ;01 thru 59 \s* ;zero or more spaces ([aApP][mM])? ;nothing or AM or PM (case insensitive) ) | ;or 24H notation w/out AM|PM ( ([0-1][0-9]|[2][0-3]|[0-9]) ;00-19 or 20-23 [\:|\-|\.] ;: or - or . ([0-5]\d) ;00-59 ) ) )$ ;End of Line
Matches
01/01/2002 04:42 | 5-12-02 04:42 AM | 01.01/02 04-42aM
Non-Matches
01-12-1999 4:50PM | 01-12-2002 15:10PM | 01-12-002 8:20PM
Author Rating: Not yet rated. Bob Duffett
Title Test Details Pattern Title
Expression
(\s*\(?0\d{4}\)?\s*\d{6}\s*)|(\s*\(?0\d{3}\)?\s*\d{3}\s*\d{4}\s*)
Description
UK Phone Number Allows leading and trailing spaces and optional spaces after the dialing code. Initially the expression I posted was \s*0\d{4}\s*\d{6}\s*|\s*0\d{3}\s*\d{7}\s* But this didn't include optional brackets e.g. (01603) 123123 or phone numbers in a London format e.g. 0208 123 1234
Matches
01603 123123 | 0207 1234567 | (0208) 123 1234
Non-Matches
123 123132
Author Rating: The rating for this expression. Joe Gass
Title Test Details Pattern Title
Expression
^([a-zA-Z0-9!@#$%^&*()-_=+;:'"|~`<>?/{}]{1,5})$
Description
This Regular expression validates a string that contains all printable characters with a minimum length of 1 and maximum length of 5. Obviously the min and max can be changed to meet the users needs. ^([a-zA-Z0-9!@#$%^&*()-_=+;:'"|~`<>?/{}]{1,5})$ This is the string, I keep getting &lt and other characters when I save it.
Matches
ilove | $%*!_ | it
Non-Matches
123456 | This is great
Author Rating: Not yet rated. Michael Matusiewicz
Title Test Details Pattern Title
Expression
^((\"[^\"\f\n\r\t\v\b]+\")|([\w\!\#\$\%\&\'\*\+\-\~\/\^\`\|\{\}]+(\.[\w\!\#\$\%\&\'\*\+\-\~\/\^\`\|\{\}]+)*))@((\[(((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9]))\.((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9]))\.((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9]))\.((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9])))\])|(((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9]))\.((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9]))\.((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9]))\.((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9])))|((([A-Za-z0-9\-])+\.)+[A-Za-z\-]+))$
Description
Email address validator. Should cover most of RFC 822, including unusual (but still valid) addresses. Does not restrict the top level domain size, but you're better off doing an nslookup or similar if you absolutely must have a valid domain. Accepts IP Addresses instead of the domain, with or without brackets. Believe it or not, this one is valid: !#$%^&*-+~/'`|{}@xyz.com Sorry looks like this site is mangling the quote and ampersand characters - you'll have to fix that yourself.
Matches
/A/Wacky/[email protected] | bob.builder@[1.1.1.1] | "blah b. blahburger"@blah.com
Non-Matches
./A/Wacky/[email protected] | bob.builder@[256.1.1.1] | -"blah b. blahburger"@blah.com
Author Rating: Not yet rated. Roger Ramjet
Title Test Details Pattern Title
Expression
(at\s)(?<fullClassName>.+)(\.)(?<methodName>[^\.]*)(\()(?<parameters>[^\)]*)(\))((\sin\s)(?<fileName>.+)(:line )(?<lineNumber>[\d]*))?
Description
Just a simple regExp to parse the stack trace. Developed when using the exception block from MS, coz they only showed the stack all bunched together. Could be used as follows: [C#] string regExParams = @"(at\s)(?<fullClassName>.+)(\.)(?<methodName>[^\.]*)(\()(?<parameters>[^\)]*)(\))((\sin\s)(?<fileName>.+)(:line )(?<lineNumber>[\d]*))?"; Regex re = new System.Text.RegularExpressions.Regex(regExParams,RegexOptions.Compiled); MatchCollection mtc; mtc = re.Matches(System.Environment.StackTrace); foreach(Match mt in mtc) { MessageBox.Show(mt.Result("${fullClassName}")); MessageBox.Show(mt.Result("${methodName}")); MessageBox.Show(mt.Result("${parameters}")); MessageBox.Show(mt.Result("${fileName}")); MessageBox.Show(mt.Result("${lineNumber}")); } Seems to work well, but use at your own peril!! Feel free to use and enhance (there's probably a lot that could be done, like getting parameters individually(?), etc)
Matches
at System.IO.__Error.WinIOError(Int32 errorCode, String str) | at ExceptionManagementQuickStartSampl
Non-Matches
ExceptionManagementQuickStartSamples.Form1.DoLogon(String userName, String password) in c:\program f
Author Rating: The rating for this expression. Mike Stancombe
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: The rating for this expression. Darren Neimke
Title Test Details Pattern Title
Expression
<[a-zA-Z]+(\s+[a-zA-Z]+\s*=\s*("([^"]*)"|'([^']*)'))*\s*/>
Description
Matches a valid &quot;empty&quot; tag (has trailing slash). Note, if you run it against a string such as &lt;img src=&quot;test.gif&quot; alt=&quot;&lt;hr /&gt;&quot;&gt; it will indeed return a match. But, the match is not at character 1 like you'd suspect, but rather it's matching the internal &lt;hr /&gt;. If you look at the source of this tag (http://concepts.waetech.com/unclosed_tags/) you'll find a whoe suite of regex's for matching html tags. Using them you could feasibly step though a document and avoid this mismatch as the outer tag would match *in totality* and you'd completely skip this inner match.
Matches
<img src="test.gif"/>
Non-Matches
<img src="test.gif"> | <img src="test.gif"a/>
Author Rating: Not yet rated. Joshua Olson
Title Test Details Pattern Title
Expression
^\w+.*$
Description
Validates any line begining with an alpha-numeric. If you need a regular expression that fails only for a zero length string. Remove the \w+. I originally attempted to post was ^.*$ but the input form would not allow it.
Matches
user name | o)(=-&amp;r443*/
Non-Matches
=stuff | .username
Author Rating: Not yet rated. Colin Albert
Title Test Details Pattern Title
Expression
^([a-zA-Z0-9]([a-zA-Z0-9\-]{0,61}[a-zA-Z0-9])?\.)+[a-zA-Z]{2,6}$
Description
Checks domain names. This validates domains based on latest specifications (RFCs 952 and 1123 dealing with hostnames and RFC 1035 dealing with domain name system requirements) except that it only includes realistic fully-qualified domains: 1. requires at least one subdomain 2. allows shortest top-level domains like &quot;ca&quot;, and &quot;museum&quot; as longest. Other validation rules: 1. Labels/parts should be seperated by period. 2. Each label/part has maximum of 63 characters. 3. First and last character of label must be alphanumeric, other characters alphanumeric or hyphen. 4. Does not check maxlength of domain which incidentally is 253 characters of text (255 binary representation). For a regular expression that matches ALL domains: ^([a-zA-Z0-9]([a-zA-Z0-9\-]{0,61}[a-zA-Z0-9])?\.)*[a-zA-Z0-9]([a-zA-Z0-9\-]{0,61}[a-zA-Z0-9])?$
Matches
regexlib.com | this.is.a.museum | 3com.com
Non-Matches
notadomain-.com | helloworld.c | .oops.org
Author Rating: The rating for this expression. Remi Sabourin
Title Test Details Pattern Title
Expression
^[^<>`~!/@\#}$%:;)(_^{&*=|'+]+$
Description
A general string validation to insure that NO malicious code or specified characters are passed through user input. This will allow you to input any characters except those specified. The expression above does not allow user input of &lt;&gt;`~!/@\#}$%:;)(_^{&amp;*=|'+. Input as many invalid characters you wish to deny. This really works!
Matches
This is a test
Non-Matches
<href = | <br> | That's it
Author Rating: Not yet rated. Brenden Salta
Title Test Details Pattern Title
Expression
<[^>]*>
Description
HTML Pattern Matching PLEASE HELP /&lt;[^&gt;]*&gt;/ig The above pattern is only successful when html tag are simple (they don't include any javascript). This mean that the pattern will fail if something like this is within the tag &lt;input type=button value=test onclick='if(n.value&gt;5)do_this();'&gt;. It will not match the entire open n close sign. How do you write a pattern that will pass all these tag so that the pattern will match from the open to the close sign and not when it just see a &gt; within a '' or &quot;&quot;. &lt;input type=button onclick='if(n.value&gt;5)do_this();'&gt; not this &lt;br&gt; &lt;input type=button onclick=&quot;n&gt;5?a():b();&quot; value=test&gt; not this &lt;br&gt; &lt;input type=button onclick=&quot;n&gt;5?a(\&quot;OK\&quot;):b('Not Ok');&quot; value=test&gt; not this &lt;br&gt; &lt;input type=button onclick='n&gt;5' value=test onmouseover=&quot;n&lt;5&amp;&amp;n&gt;8&quot; onmouseout='if(n&gt;5)alert(\'True\');else alert(&quot;False&quot;)'&gt; not this &lt;br&gt; Any help would be greatly appreciate. Thanks a whole lot. Logan
Matches
<html>
Non-Matches
abc
Author Rating: The rating for this expression. Logan Tran
Title Test Details Pattern Title
Expression
[^!~/&gt;&lt;\|/#%():;{}`_-]
Description
Trying to remove all these characters in the regular expression: still working on it !~/[&gt;&lt;*\|]/#$%^&amp;():;{},?`_-
Matches
Soma | Infy | every
Non-Matches
&lt; | &gt; | !
Author Rating: Not yet rated. Somasundaram Thirugnanam
Title Test Details Pattern Title
Expression
^(Function|Sub)(\s+[\w]+)\([^\(\)]*\)
Description
Updated, changed [\w]* to [\w]+ because pattern should not match Sub (), there would be no function name which would be incorrect. Will extract function declarations from ASP or also VB I assume. Will even capture declarations that break across new lines or ones that use the underscore(line continuation character) in Microsoft's VB, VBA, ASP, etc. Had to put this together to document some code on a project and didn't see anything like it on the web. I hope it helps out anyone else who has to re-engineer ASP or VB code.
Matches
Function MyFunc(Arg1, Arg2, Arg3, Arg4)
Non-Matches
'This is a comment for MyFunc(Arg1,Arg2,Arg3) and this regexp wouldn't work.
Author Rating: Not yet rated. James Fal
Title Test Details Pattern Title
Expression
\w+[\w-\.]*\@\w+((-\w+)|(\w*))\.[a-z]{2,3}$|^([0-9a-zA-Z'\.]{3,40})\*|([0-9a-zA-Z'\.]+)@([0-9a-zA-Z']+)\.([0-9a-zA-Z']+)$|([0-9a-zA-Z'\.]+)@([0-9a-zA-Z']+)\*+$|^$
Description
This regular expression is for admitting wild card searches on Emails the wild card character is * and in my case will only allow to do the search when the * is place after the first 3 alphanumeric characters. If you need to modify this behavior change the {3,40} to {n,m} where n is how many characters before the * and m is the total number if characters.
Matches
jdh* | jss.js* | [email protected]
Non-Matches
j* | js*
Author Rating: Not yet rated. Julio de la Yncera
Title Test Details Pattern Title
Expression
^(?!\d[1]{2}|[5]{3})([2-9]\d{2})([. -]*)\d{4}$
Description
Validates *usable* US telephone numbers (possibly Canadian and Caribbean Islands as well?) Numbers cannot beginning with zero, one, (any number)11, or 555. It will allow either a hyphen, space or period as a separator. Technically (and contrary to popular belief) most 555- numbers ARE valid numbers [see http://www.nanpa.com/nas/public/form555MasterReport.do?method=display555MasterReport ] but they are unlikely to be used by normal folks. Therefore, excluding them with this regex is useful to prevent bogus/fraudulent telephone numbers in forms. FYI, the fictitious 555- numbers used in the movies and TV are only in the range of 555-0100 through 555-0199. Not very many, huh?
Matches
222-2222 | 295-5000
Non-Matches
555-1234 | 411-5555 | 099-9999
Author Rating: Not yet rated. JP Honeywell
Title Test Details email address (RFC 2822 mailbox)
Expression
^((?>[a-zA-Z\d!#$%&'*+\-/=?^_`{|}~]+\x20*|"((?=[\x01-\x7f])[^"\\]|\\[\x01-\x7f])*"\x20*)*(?<angle><))?((?!\.)(?>\.?[a-zA-Z\d!#$%&'*+\-/=?^_`{|}~]+)+|"((?=[\x01-\x7f])[^"\\]|\\[\x01-\x7f])*")@(((?!-)[a-zA-Z\d\-]+(?<!-)\.)+[a-zA-Z]{2,}|\[(((?(?<!\[)\.)(25[0-5]|2[0-4]\d|[01]?\d?\d)){4}|[a-zA-Z\d\-]*[a-zA-Z\d]:((?=[\x01-\x7f])[^\\\[\]]|\\[\x01-\x7f])+)\])(?(angle)>)$
Description
This accepts RFC 2822 email addresses in the form:<br> [email protected] OR<br> Blah &lt;[email protected]&gt;<br> <br> RFC 2822 email 'mailbox':<br> mailbox = name-addr | addr-spec<br> name-addr = [display-name] "<" addr-spec ">"<br> addr-spec = local-part "@" domain<br> domain = rfc2821domain | rfc2821domain-literal<br> <br> local-part conforms to RFC 2822.<br> <br> domain is either:<br> An rfc 2821 domain (EXCEPT that the final sub-domain must consist of 2 or more letters only).<br> OR<br> An rfc 2821 address-literal.<br> (Note, no attempt is made to fully validate an IPv6 address-literal.)<br> <br> Notes:<br> This pattern uses (.NET/Perl only?) features named group "(?&lt;name&gt;)" and alternation/IF (?(name)).<br> <br> See <a href="http://regexadvice.com/forums/permalink/26742/26742/ShowThread.aspx#26742">this regexadvice.com thread</a> for more info, including a version that does not use .NET features.<br> <br> RFC 2822 (and 822) do allow embedded comments, whitespace, and newlines within *some* parts of an email address, but this pattern above DOES NOT.<br> <br> RFC 2822 (and 822) allow the domain to be a simple domain with NO ".", but this pattern requires a compound domain at least one "." in the domain name, as per RFC 2821 (4.1.2).<br> <br> RFC 2822 allows/disallows certain whitespace characters in parts of an email address, such as TAB, CR, LF BUT the pattern above does NOT test for these, and assumes that they are not present in the string (on the basis that these characters are hard to enter into an edit box).
Matches
[email protected] | Name Surname <[email protected]> | "b. blah"@blah.co.nz
Non-Matches
name [email protected] | name."surname"@blah.com | [email protected]
Author Rating: The rating for this expression. Mark Cranness
Title Test Details Pattern Title
Expression
X-Spam-Level:\s[*]{11}
Description
Matches SpamAsssasin score above an arbitrary number. Allows sorting of spam based on SpamAssassin score. * should be replaced the symbol configured in SpamAssassin.
Matches
X-Spam-Level: ************
Non-Matches
X-Spam-Level: **
Author Rating: Not yet rated. Chris Price
Change page:   |    Displaying page 1 of 7 pages; Items 1 to 20

Copyright © 2001-2024, RegexAdvice.com | ASP.NET Tutorials