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 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 (X)HTML click events
Expression
(?i:on(blur|c(hange|lick)|dblclick|focus|keypress|(key|mouse)(down|up)|(un)?load|mouse(move|o(ut|ver))|reset|s(elect|ubmit)))
Description
This regex will match all the valid on event attributes in HTML 4.01/XHTML 1.0
Matches
onclick | onsubmit | onmouseover
Non-Matches
click | onandon | mickeymouse
Author Rating: The rating for this expression. Michael Ash
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
(\[(\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
(?'openingTag'&lt;) \s*? (?'tagName'\w+) # Once we've got the tagname, match zero # or more attribute sequences (\s*? # Atomic Grouping for efficiency (?&gt; (?!=[\/\?]?&gt;) # Lookahead so that we can fail quickly # match Attribute pieces (?'attribName'\w+) (?:\s* (?'attribSign'=) \s* ) (?'attribValue' (?:\'[^\']*\'|\&quot;[^\&quot;]*\&quot;|[^ &gt;]+) ) ) )* \s*? # Closing Tag can be either &gt; or /&gt; (?'closeTag'[\/\?]?&gt;)
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
&lt;head&gt; | &lt;script language=javascript&gt; | &lt;input type=submit &gt;
Non-Matches
&lt;/head&gt;
Author Rating: The rating for this expression. Darren Neimke
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
^[^<>`~!/@\#}$%:;)(_^{&*=|'+]+$
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 Pattern Title
Expression
&lt;!--[\s\S]*?--[ \t\n\r]*&gt;
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 &gt;
Matches
&lt;!-- anything -- &gt; | &lt;!-- anything -&gt; -&gt; --&gt;
Non-Matches
&lt;!-- something -- and more &gt;
Author Rating: The rating for this expression. Kristijan Mitrovic
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
\{\\\*\\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
(?<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
&amp;(?![a-zA-Z]{2,6};|#[0-9]{3};)
Description
The goal of this regular expression is to replace all &amp; (ampersand) characters by &amp;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
&amp;ThisIsTooLong; | Lilo &amp; Stich | &amp;l;
Non-Matches
&amp;lt; | &amp;brvbar; | &amp;#166;
Author Rating: The rating for this expression. Frederick Samson
Title Test Details Quoted string
Expression
^(\x22|\x27)((?!\1).|\1{2})*\1$
Description
The regex validate a quoted string in VBScript or Ansi SQL. The string may contain the containing quote character if it is escaped by being doubled up. In VB/VBScript two double quotes within a string enclosed in double qoutes translate into one double quote within the string In SQL two single quotes within a string enclosed in single qoutes translate into one single quote within the string
Matches
"To quote Yoda (""Do, or do not. There is no 'try'"" )"
Non-Matches
'This won't validate' | "He said "Ok.""
Author Rating: The rating for this expression. Michael Ash
Title Test Details Enitity notation
Expression
& (?ni:\# # if a pound sign follow ampsand look for number ((x # if x follow pound sign accept hex value up to 5 digits ([\dA-F]){1,5} ) | # otherwise accept decimal number between 0 - 1048575 (104857[0-5] |10485[0-6]\d |1048[0-4]\d\d |104[0-7]\d{3} |10[0-3]\d{4} |0?\d{1,6}) ) | # no pound sign after ampersand ([A-Za-z\d.]{2,31}) #accept ASCII alphanumeric and period ); #end with semi-colon.
Description
This regex can be used to find general entites in HTML, XML and SGML files. The entity can consist of 1) an ampsand (&amp;) 2) followed by (a) ASCII alphanumerics or period between 2 and 31 characters or (b) a pound sign # (i) followed by an x followed by a unicode value up to 5 hex digits or (ii) followed by a decimal value from 0 to 1048575 3) ending with a semi-colon (;)
Matches
&quote; | &#169; | &#x00027;
Non-Matches
& | &#Hello; | &#Xray;
Author Rating: The rating for this expression. Michael Ash
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: The rating for this expression. Chris Craft
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
&lt;!--[\s\S]*?--&gt;
Description
Removes pesky comments and commented javascript from HTML
Matches
&lt;!-- comments --&gt; | &lt;!-- x = a &gt; b - 3 --&gt;
Non-Matches
&lt;COMMENTS&gt;this is a comment&lt;/COMMENTS&gt;
Author Rating: The rating for this expression. Lewis Moten
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 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
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
Change page:   |    Displaying page 1 of 4 pages; Items 1 to 20

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