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

Please support RegExLib Sponsors

Sponsors

Browse Expressions by Category

63 regular expressions found in this category!

Expressions in category: Markup/Code

Change page:   |    Displaying page 3 of 4 pages; Items 41 to 60
Title Test Details Pattern Title
Expression
</?(\w+)(\s*\w*\s*=\s*("[^"]*"|'[^']'|[^>]*))*|/?>
Description
Matches HTML of XML tags, with or without attributes (single-, double-, or non-quoted), closing tags, or self-closing singleton tags.
Matches
<font color="blue"> | </font> | <br />
Non-Matches
this is a test...
Author Rating: Not yet rated. Jean-Philip Losier
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: Not yet rated. Darren Neimke
Title Test Details Pattern Title
Expression
^(#){1}([a-fA-F0-9]){6}$
Description
Matches HTML Color strings. Like #FFFFFF is white and #000000 is black and #FF0000 is red and so on...
Matches
#FFFFFF | #FF3421 | #00FF00
Non-Matches
232323 | f#fddee | #fd2
Author Rating: Not yet rated. Mladen Mihajlovic
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: Not yet rated. 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: Not yet rated. Lewis Moten
Title Test Details Pattern Title
Expression
&lt;[^&gt;]*name[\s]*=[\s]*&quot;?[^\w_]*&quot;?[^&gt;]*&gt;
Description
This RX is used to find get all named tags in an html string. If you find a problem with it, please email [email protected]
Matches
&lt;input type = text name = &quot;bob&quot;&gt; | &lt;select name = &quot;fred&quot;&gt; | &lt;form
Non-Matches
&lt;input type = submit&gt; | &lt;font face = &quot;arial&quot;&gt; | The drity brown fox stank like
Author Rating: Not yet rated. Andrew Freese
Title Test Details Pattern Title
Expression
&lt;[^&gt;]*\n?.*=(&quot;|')?(.*\.jpg)(&quot;|')?.*\n?[^&lt;]*&gt;
Description
Match any image insert in a tag . simply replace the .jpg in the pattern whit a variable of content type ex:.swf,.js,.gif and loop the pattern to retrieve all tag whit the contenttype pass trought.... Very useful when you have people uploading html document in your site and you want to retrieve all dependecy.
Matches
&lt;td background=&quot;../img/img.jpg&quot; &gt; | &lt;img src=img.jpg &gt; | &lt;img src='img.jpg'
Non-Matches
= img.jpg | img.jpg
Author Rating: Not yet rated. Marc-Antoine Latour
Title Test Details Pattern Title
Expression
<blockquote>(?:\s*([^<]+)<br>\s*)+</blockquote>
Description
Use this regular expression pattern to get the string1, string2, string3 .... from &lt;blockquote&gt;string1&lt;br&gt;string2&lt;br&gt;string3&lt;br&gt;&lt;/blockquote&gt;
Matches
<blockquote>string1<br>string2<br>string3<br></blockquote>
Non-Matches
..
Author Rating: Not yet rated. Waheed Khan
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: Not yet rated. Lewis Moten
Title Test Details Pattern Title
Expression
&amp;lt;/?([a-zA-Z][-A-Za-z\d\.]{0,71})(\s+(\S+)(\s*=\s*([-\w\.]{1,1024}|&amp;quot;[^&amp;quot;]{0,1024}&amp;quot;|'[^']{0,1024}'))?)*\s*&amp;gt;
Description
Searches for tags and there atributes according to the HTML 2.0 specification to limit length of tags to 72 characters, and length of attribute values to 1024 characters.
Matches
&amp;lt;IMG src='stars.gif' alt=&amp;quot;space&amp;quot; height=1&amp;gt;
Non-Matches
this is not a tag
Author Rating: Not yet rated. Lewis Moten
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
&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: Not yet rated. Frederick Samson
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: Not yet rated. 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: Not yet rated. Simon Christensen
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: Not yet rated. Michael Ash
Title Test Details Pattern Title
Expression
(<meta\s+)*((name\s*=\s*("|')(?<name>[^'("|')]*)("|')){1}|content\s*=\s*("|')(?<content>[^'("|')]*)("|')|scheme\s*=\s*("|')(?<scheme>[^'("|')]*)("|'))
Description
Capture the attributes &quot;content&quot;, &quot;name&quot; and &quot;scheme&quot; used to parse META tags from any XHTML or HTML input. Useful for developers looking for expresions to parse &amp; get Dublin Core single elements from HTML pages.
Matches
<meta name="DC.subject" content="metadata"/>
Non-Matches
the other html constructs
Author Rating: Not yet rated. Ernesto Giralt
Title Test Details Pattern Title
Expression
^(?&lt;path&gt;(/?(?&lt;step&gt;\w+))+)(?&lt;predicate&gt;\[(?&lt;comparison&gt;\s*(?&lt;lhs&gt;@\w+)\s*(?&lt;operator&gt;&lt;=|&gt;=|&lt;&gt;|=|&lt;|&gt;)\s*(?&lt;rhs&gt;('[^']*'|&quot;[^&quot;]*&quot;))\s*(and|or)?)+\])*$
Description
Simple parser of XPath, it doesn't handle the more complex statements but can be of use in some situations.
Matches
/root/child1/child2[ @param='value' ] | child1[@param &gt;= &quot;1&quot; and @foo &lt; 'asdf&quot;
Non-Matches
/root/*[ local-name() = 'child1' ][ child2/@param='value ]/child2
Author Rating: Not yet rated. Tim Walters
Title Test Details Pattern Title
Expression
(?s)/\*.*\*/
Description
Matches
/* .................... */ | /* imagine lots of lines here */
Non-Matches
*/ malformed opening tag */ | /* malformed closing tag /*
Author Rating: Not yet rated. Darren Neimke
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: Not yet rated. Ashish Sheth
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
Change page:   |    Displaying page 3 of 4 pages; Items 41 to 60

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