63 regular expressions found in this category!
Displaying page
of
pages;
Items to
| Title |
Test
Details
Pattern Title
|
| Expression |
(\[(\w+)\s*(([\w]*)=('|")?([a-zA-Z0-9|:|\/|=|-|.|\?|&]*)(\5)?)*\])([a-zA-Z0-9|:|\/|=|-|.|\?|&|\s]+)(\[\/\2\]) |
| Description |
Peseudo-HTML code matcher. Allows for one parameter within the first tag (name is optional), the value of which can be optionally delimited by either double or single quotes. Uses backreferencing to ensure that the end and start tags match, and that any single or double quotes match. Very useful for web forums or any situation where users may be prompted to enter text for display on a webpage somewhere, as it can be quickly processed into HTML without allowing HTML to be specified within the input itself (which may pose a security risk). |
| Matches |
[link url="http://www.domain.com/file.extension?getvar=value&secondvar=value"]Link[/li |
| Non-Matches |
[a]whatever[/b] | [a var1=something var2=somethingelse]whatever[/a] | [a]whatever[a] |
| Author |
Rating:
Simon Christensen
|
| Title |
Test
Details
Pattern Title
|
| Expression |
<([^\s>]*)(\s[^<]*)> |
| Description |
grab all tags attributes...
<img src="truc"> returns :
<
(1:img)
(2: src="truc")
>
i use it to clean html pages to grab infos...
use a RegEx Replace with "<$1>" to keep only tags codes... |
| Matches |
<img src="truc"> | <body background='...'> | <p align='left'> |
| Non-Matches |
<br> | </body> | <p> |
| Author |
Rating:
Tanguy Pruvot
|
| 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 |
(SELECT\s[\w\*\)\(\,\s]+\sFROM\s[\w]+)|
(UPDATE\s[\w]+\sSET\s[\w\,\'\=]+)|
(INSERT\sINTO\s[\d\w]+[\s\w\d\)\(\,]*\sVALUES\s\([\d\w\'\,\)]+)|
(DELETE\sFROM\s[\d\w\'\=]+) |
| Description |
This RE match the SQL Basics Queries (SELECT, UPDATE, INSERT and DELETE). |
| Matches |
SELECT * FROM TABLE | UPDATE TABLE SET FIELD=VALUE WHERE ID_FIELD=VALUE_ID | DELETE FROM TABLE WHERE |
| Non-Matches |
SELECT TABLE | UPDATE SET TABLE | INSERT INTO FIELD=VALUE TABLE |
| Author |
Rating:
Gabriel Fróes
|
| 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:
James Fal
|
| 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 |
^[^<>`~!/@\#}$%:;)(_^{&*=|'+]+$ |
| 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 <>`~!/@\#}$%:;)(_^{&*=|'+. 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:
Brenden Salta
|
| Title |
Test
Details
Pattern Title
|
| Expression |
<[^>]*> |
| Description |
HTML Pattern Matching
PLEASE HELP
/<[^>]*>/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 <input type=button value=test onclick='if(n.value>5)do_this();'>. 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 > within a '' or "".
<input type=button onclick='if(n.value>5)do_this();'> not this <br>
<input type=button onclick="n>5?a():b();" value=test> not this <br>
<input type=button onclick="n>5?a(\"OK\"):b('Not Ok');" value=test> not this <br>
<input type=button onclick='n>5' value=test onmouseover="n<5&&n>8" onmouseout='if(n>5)alert(\'True\');else alert("False")'> not this <br>
Any help would be greatly appreciate. Thanks a whole lot.
Logan |
| Matches |
<html> |
| Non-Matches |
abc |
| Author |
Rating:
Logan Tran
|
| Title |
Test
Details
HTML 4.01 Elements
|
| Expression |
(<\/?)(?i:(?<element>a(bbr|cronym|ddress|pplet|rea)?|b(ase(font)?|do|ig|lockquote|ody|r|utton)?|c(aption|enter|ite|(o(de|l(group)?)))|d(d|el|fn|i(r|v)|l|t)|em|f(ieldset|o(nt|rm)|rame(set)?)|h([1-6]|ead|r|tml)|i(frame|mg|n(put|s)|sindex)?|kbd|l(abel|egend|i(nk)?)|m(ap|e(nu|ta))|no(frames|script)|o(bject|l|pt(group|ion))|p(aram|re)?|q|s(amp|cript|elect|mall|pan|t(r(ike|ong)|yle)|u(b|p))|t(able|body|d|extarea|foot|h|itle|r|t)|u(l)?|var))(\s(?<attr>.+?))*> |
| Description |
This RE will match all the valid elements in HTML 4.01 |
| Matches |
<HTML> | <a href="link.html">Link</a> |
| Non-Matches |
<xml> | <phonytag> | <image> |
| Author |
Rating:
Michael Ash
|
| Title |
Test
Details
Pattern Title
|
| Expression |
\xA9 |
| Description |
Matches the copyright symbol (&copy;). Pretty simple, yet I dont think existed on RegExLib before. |
| Matches |
© |
| Non-Matches |
anything |
| Author |
Rating:
Roman Lukyanenko
|
| 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:
Darren Neimke
|
| Title |
Test
Details
Pattern Title
|
| Expression |
(?s)( class=\w+(?=([^<]*>)))|(<!--\[if.*?<!\[endif\]-->)|(<!\[if !\w+\]>)|(<!\[endif\]>)|(<o:p>[^<]*</o:p>)|(<span[^>]*>)|(</span>)|(font-family:[^>]*[;'])|(font-size:[^>]*[;'])(?-s) |
| Description |
Word HTML cleanup code. Use this expression to get rid of most of the stuff that Word adds to an HTML document such as: lots of span elements, font-family and font-size style attributes, class attributes, a whole bunch of if-then statements. Use this expression in a regex.replace(originalHtml, regExpr, "").
|
| Matches |
<span> |
| Non-Matches |
<table> |
| Author |
Rating:
Peter Donker
|
| Title |
Test
Details
Pattern Title
|
| Expression |
^[a-zA-Z_]{1}[a-zA-Z0-9_]+$ |
| Description |
This expression validates for valid C# or C++ identifier |
| Matches |
_12ffsd | abcd123 | abcd_23232 |
| Non-Matches |
..// | ..13e232 | abcd 3232 |
| Author |
Rating:
Ashish Sheth
|
| Title |
Test
Details
Pattern Title
|
| Expression |
<!--[\s\S]*?--[ \t\n\r]*> |
| Description |
As I could understand the HTML standard, this is the valid reg.exp. for comments.
The only differenc from the last one is that the comment can be terminated by two minuses followed by none OR SOME space caracters and then by character > |
| Matches |
<!-- anything -- > | <!-- anything -> -> --> |
| Non-Matches |
<!-- something -- and more > |
| Author |
Rating:
Kristijan Mitrovic
|
| Title |
Test
Details
Pattern Title
|
| Expression |
(?<commentblock>((?m:^[\t ]*\/{2}[^\n\r\v\f]+[\n\r\v\f]*){2,})|(\/\*[\w\W]*?\*\/)) |
| Description |
This expression will match comment blocks in javascript, c, c++, etc
I wrote this as a named group called "commentblock", as I like to use it with other expressions.
It avoids single line comments or inline commented code (which are not considered comment "blocks") unless the comments are in a /* text */ comment style
could not create a multiline example in the matching examples, here is what I tried to enter
// Some text
//(must be two or more lines long and each line may only be preceded by whitespace)
|
| Matches |
/* Some text (may be any number of lines) */ |
| Non-Matches |
// Some text (only a single line) | Some code // comment here (even if next line has comment) | /* S |
| Author |
Rating:
Chris Strolia-Davis
|
| Title |
Test
Details
Pattern Title
|
| Expression |
&(?![a-zA-Z]{2,6};|#[0-9]{3};) |
| Description |
The goal of this regular expression is to replace all & (ampersand) characters by &amp; if they are not the start of HTML entities. I used
http://www.w3schools.com/html/html_entitiesref.asp as a reference. You can then use RegExp Replace method to do the work. Was helpful for me, might helpful be for you... |
| Matches |
&ThisIsTooLong; | Lilo & Stich | &l; |
| Non-Matches |
&lt; | &brvbar; | &#166; |
| Author |
Rating:
Frederick Samson
|
| Title |
Test
Details
Pattern Title
|
| Expression |
(?s)/\*.*\*/ |
| Description |
|
| Matches |
/* .................... */ | /* imagine lots of lines here */ |
| Non-Matches |
*/ malformed opening tag */ | /* malformed closing tag /* |
| Author |
Rating:
Darren Neimke
|
| Title |
Test
Details
Pattern Title
|
| Expression |
<[a-zA-Z][^>]*\son\w+=(\w+|'[^']*'|"[^"]*")[^>]*> |
| Description |
Find HTML tags that have javascript events attached to them. |
| Matches |
<IMG onmouseover="window.close()"> |
| Non-Matches |
<IMG src="star.gif"> |
| Author |
Rating:
Lewis Moten
|
| Title |
Test
Details
Pattern Title
|
| Expression |
<!--[\s\S]*?--> |
| Description |
Removes pesky comments and commented javascript from HTML |
| Matches |
<!-- comments --> | <!-- x = a > b - 3 --> |
| Non-Matches |
<COMMENTS>this is a comment</COMMENTS> |
| Author |
Rating:
Lewis Moten
|
| Title |
Test
Details
Pattern Title
|
| Expression |
^#?([a-f]|[A-F]|[0-9]){3}(([a-f]|[A-F]|[0-9]){3})?$ |
| Description |
Tests for valid HTML hexadecimal color codes. The # symbol is optional. And it will except either the 3 digit form for the 216 Web safe colors, or the full 6 digit form. I am use it on my site to allow users to customize the site's colors. |
| Matches |
#00ccff | #039 | ffffcc |
| Non-Matches |
blue | 0x000000 | #ff000 |
| Author |
Rating:
Chris Craft
|
Displaying page
of
pages;
Items to