63 regular expressions found in this category!
Displaying page
of
pages;
Items to
| 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:
Darren Neimke
|
| 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 |
^(?<Code>([^"']|"[^"]*")*)'(?<Comment>.*)$ |
| Description |
This expression separates a Visual Basic (VB) source code line into the code part and the comment part (if any, following an apostrophe character not enclosed in quote marks). |
| Matches |
a = b ' Comment | a = "xy'z" ' Comment |
| Non-Matches |
a = b | rem not supported |
| Author |
Rating:
Robert Altman
|
| 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
Web Colors (216)
|
| Expression |
^#?(([fFcC0369])\2){3}$ |
| Description |
Matches the 216 web colors with or without the '#' sign. |
| Matches |
#FFFFFF | FFCC00 | 003300 |
| Non-Matches |
#FFFFF | EFCC00 | 030303 |
| Author |
Rating:
Dean Dal Bozzo
|
| Title |
Test
Details
Pattern Title
|
| Expression |
\{\\\*\\bkmkstart\s(.*?)\} |
| Description |
Applied to a .RTF document, returns all the names of the# bookmarks. Useful to retrieve# dinamically# the list of bookmarks from a document. |
| Matches |
{\*\bkmkstart TagAmountDigits} | ({\*\bkmkstart TagAmountText} |
| Non-Matches |
{\*\bkmkend TagAmountText} |
| Author |
Rating:
Fernando Eklipse
|
| Title |
Test
Details
Pattern Title
|
| Expression |
<!--.*?--> |
| Description |
|
| Matches |
<!-- <h1>this text has been removed</h1> --> | <!-- yada --> |
| Non-Matches |
<h1>this text has not been removed</h1> |
| Author |
Rating:
Tony Austin
|
| 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 |
href=[\"\'](http:\/\/|\.\/|\/)?\w+(\.\w+)*(\/\w+(\.\w+)?)*(\/|\?\w*=\w*(&\w*=\w*)*)?[\"\'] |
| Description |
I wrote up this regular expression to fetch the href attribute found in <a> tags as well as a few other HTML tags. |
| Matches |
href="www.yahoo.com" | href="http://localhost/blah/" | href="eek" |
| Non-Matches |
href="" | href=eek | href="bad example" |
| Author |
Rating:
Andrew Lee
|
| 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 |
(?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 |
<(?<tag>.*).*>(?<text>.*)</\k<tag>> |
| Description |
Match the content of any regular tag/s |
| Matches |
<body>Content here</body> |
| Non-Matches |
<body>Content here<body> |
| Author |
Rating:
luca milan
|
| Title |
Test
Details
XML Tag
|
| Expression |
<(\w+)(\s(\w*=".*?")?)*((/>)|((/*?)>.*?</\1>)) |
| Description |
This RE will match XML tag elements. All elements must be closed. Won't match nested tags
|
| Matches |
<body> text<br/>More Text </body> | <a href="link.html">Link</a |
| Non-Matches |
<p> Some Text <p> | <hr> | <html> |
| Author |
Rating:
Michael Ash
|
| Title |
Test
Details
Pattern Title
|
| Expression |
('.*$|Rem((\t| ).*$|$)|"(.|"")*?") |
| Description |
Pulls out comments (both Rem and ') and string literals from VB or VBScript. Usefull for spell checking or review.
Notes: The VBScript for "Rem" documentation says that it must be followed by a space but VBScript seems to accept tab characters as well.
The multiline flag is assumed for this search. |
| Matches |
' This is a comment | Rem This is a comment | " This is a string with "" and ' " |
| Non-Matches |
" This is not a string | RemThis is not a comment | This is not a comment or a string |
| Author |
Rating:
Ed Preston
|
| Title |
Test
Details
Pattern Title
|
| Expression |
(?<HTML><a[^>]*href\s*=\s*[\"\']?(?<HRef>[^"'>\s]*)[\"\']?[^>]*>(?<Title>[^<]+|.*?)?</a\s*>) |
| Description |
Powerful href extractor for HTML Element A.
Groups extracted result separately that you can easily use HTML Element, URI or its title.
These may be useful to:
(?<HTML><area[^>]*href\s*=\s*[\"\']?(?<HRef>[^"'>\s]*)[\"\']?[^>]*>)
(?<HTML><form[^>]*action\s*=\s*[\"\']?(?<HRef>[^"'>\s]*)[\"\']?[^>]*>)
(?<HTML><frame[^>]*scr\s*=\s*[\"\']?(?<HRef>[^"'>\s]*)[\"\']?[^>]*>)
(?<HTML><iframe[^>]*scr\s*=\s*[\"\']?(?<HRef>[^"'>\s]*)[\"\']?[^>]*>)
(?<HTML><link[^>]*href\s*=\s*[\"\']?(?<HRef>[^"'>\s]*)[\"\']?[^>]*>) |
| Matches |
<a href='http://www.regexlib.com'>Text</a> | <a href="...'>Text</a> | & |
| Non-Matches |
all other html tags |
| Author |
Rating:
Aivar Holyfield
|
| 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 |
"([^"](?:\\.|[^\\"]*)*)" |
| 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 |
(?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
|
Displaying page
of
pages;
Items to