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

Please support RegExLib Sponsors

Hosting Spotlight

Sponsors

Browse Expressions by Category

63 regular expressions found in this category!

Expressions in category: Markup/Code

Change page:   |    Displaying page 1 of 4 pages; Items 1 to 20
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: The rating for this expression. 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: The rating for this expression. 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 &quot;commentblock&quot;, as I like to use it with other expressions. It avoids single line comments or inline commented code (which are not considered comment &quot;blocks&quot;) 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: The rating for this expression. 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: The rating for this expression. 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 &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: The rating for this expression. 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: The rating for this expression. 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: The rating for this expression. Fernando Eklipse
Title Test Details Pattern Title
Expression
&lt;!--.*?--&gt;
Description
Matches
&lt;!-- &lt;h1&gt;this text has been removed&lt;/h1&gt; --&gt; | &lt;!-- yada --&gt;
Non-Matches
&lt;h1&gt;this text has not been removed&lt;/h1&gt;
Author Rating: The rating for this expression. Tony Austin
Title Test Details Pattern Title
Expression
(\[(\w+)\s*(([\w]*)=('|&quot;)?([a-zA-Z0-9|:|\/|=|-|.|\?|&amp;]*)(\5)?)*\])([a-zA-Z0-9|:|\/|=|-|.|\?|&amp;|\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=&quot;http://www.domain.com/file.extension?getvar=value&amp;secondvar=value&quot;]Link[/li
Non-Matches
[a]whatever[/b] | [a var1=something var2=somethingelse]whatever[/a] | [a]whatever[a]
Author Rating: The rating for this expression. 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 &lt;a&gt; 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: The rating for this expression. Andrew Lee
Title Test Details Pattern Title
Expression
[0][x][0-9a-fA-F]+
Description
Matches hexadecimal values like in c-sourcecode exists.
Matches
0x0ffe
Non-Matches
x0ffe
Author Rating: The rating for this expression. Andreas Schiller
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: The rating for this expression. 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: The rating for this expression. 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: The rating for this expression. 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
&lt;body&gt; text&lt;br/&gt;More Text &lt;/body&gt; | &lt;a href=&quot;link.html&quot;&gt;Link&lt;/a
Non-Matches
&lt;p&gt; Some Text &lt;p&gt; | &lt;hr&gt; | &lt;html&gt;
Author Rating: The rating for this expression. Michael Ash
Title Test Details Pattern Title
Expression
('.*$|Rem((\t| ).*$|$)|&quot;(.|&quot;&quot;)*?&quot;)
Description
Pulls out comments (both Rem and ') and string literals from VB or VBScript. Usefull for spell checking or review. Notes: The VBScript for &quot;Rem&quot; 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 | &quot; This is a string with &quot;&quot; and ' &quot;
Non-Matches
&quot; This is not a string | RemThis is not a comment | This is not a comment or a string
Author Rating: The rating for this expression. Ed Preston
Title Test Details Pattern Title
Expression
(?&lt;HTML&gt;&lt;a[^&gt;]*href\s*=\s*[\&quot;\']?(?&lt;HRef&gt;[^&quot;'&gt;\s]*)[\&quot;\']?[^&gt;]*&gt;(?&lt;Title&gt;[^&lt;]+|.*?)?&lt;/a\s*&gt;)
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: (?&lt;HTML&gt;&lt;area[^&gt;]*href\s*=\s*[\&quot;\']?(?&lt;HRef&gt;[^&quot;'&gt;\s]*)[\&quot;\']?[^&gt;]*&gt;) (?&lt;HTML&gt;&lt;form[^&gt;]*action\s*=\s*[\&quot;\']?(?&lt;HRef&gt;[^&quot;'&gt;\s]*)[\&quot;\']?[^&gt;]*&gt;) (?&lt;HTML&gt;&lt;frame[^&gt;]*scr\s*=\s*[\&quot;\']?(?&lt;HRef&gt;[^&quot;'&gt;\s]*)[\&quot;\']?[^&gt;]*&gt;) (?&lt;HTML&gt;&lt;iframe[^&gt;]*scr\s*=\s*[\&quot;\']?(?&lt;HRef&gt;[^&quot;'&gt;\s]*)[\&quot;\']?[^&gt;]*&gt;) (?&lt;HTML&gt;&lt;link[^&gt;]*href\s*=\s*[\&quot;\']?(?&lt;HRef&gt;[^&quot;'&gt;\s]*)[\&quot;\']?[^&gt;]*&gt;)
Matches
&lt;a href='http://www.regexlib.com'&gt;Text&lt;/a&gt; | &lt;a href=&quot;...'&gt;Text&lt;/a&gt; | &
Non-Matches
all other html tags
Author Rating: The rating for this expression. 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: The rating for this expression. Gabriel Fróes
Title Test Details Pattern Title
Expression
&quot;([^&quot;](?:\\.|[^\\&quot;]*)*)&quot;
Description
Matches C style strings allowing for escaped string delimiters to be included in the match. ALTERED 13-Dec-2003 ------------------- Previous pattern was : &quot;([^&quot;](?:\\.|[^\\&quot;]*)*)&quot; Changed to: &quot;([^&quot;]*(?:\\.|[^\\&quot;]*)*)&quot; Making the first character after the opening quote optional allows the pattern to match on empty quotes: &quot;&quot;.
Matches
&quot;This is a \&quot;string\&quot;.&quot;
Non-Matches
&quot;This is a \&quot;string\&quot;.
Author Rating: The rating for this expression. Darren Neimke
Title Test Details Pattern Title
Expression
(?s)( class=\w+(?=([^&lt;]*&gt;)))|(&lt;!--\[if.*?&lt;!\[endif\]--&gt;)|(&lt;!\[if !\w+\]&gt;)|(&lt;!\[endif\]&gt;)|(&lt;o:p&gt;[^&lt;]*&lt;/o:p&gt;)|(&lt;span[^&gt;]*&gt;)|(&lt;/span&gt;)|(font-family:[^&gt;]*[;'])|(font-size:[^&gt;]*[;'])(?-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, &quot;&quot;).
Matches
&lt;span&gt;
Non-Matches
&lt;table&gt;
Author Rating: The rating for this expression. Peter Donker
Change page:   |    Displaying page 1 of 4 pages; Items 1 to 20

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