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 2 of 4 pages; Items 21 to 40
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
&lt;(?:[^&quot;']+?|.+?(?:&quot;|').*?(?:&quot;|')?.*?)*?&gt;
Description
This will match all tags in a string, it's good for stripping HTML or XML tags to get the plain text.It works with attributes that include javascript or &quot;&lt;&gt;&quot;. It will match all these &lt;hr size=&quot;3&quot; noshade color=&quot;#000000&quot; align=&quot;left&quot;&gt; &lt;p style=&quot;margin-top:0px;margin-bottom:0px&quot; align=&quot;center&quot;&gt;&lt;font face=&quot;Times New Roman&quot; size=&quot;5&quot;&gt;&lt;b&gt;UNITED STATES&lt;/b&gt;&lt;/font&gt;&lt;/p&gt; &lt;input type=button onclick='if(n.value&gt;5)do_this();'&gt; not this &lt;br&gt; &lt;input type=button onclick=&quot;n&gt;5?a():b();&quot; value=test&gt; not this &lt;br&gt; &lt;input type=button onclick=&quot;n&gt;5?a(\&quot;OK\&quot;):b('Not Ok');&quot; value=test&gt; not this &lt;br&gt; &lt;input type=button onclick='n&gt;5' value=test onmouseover=&quot;n&lt;5&amp;&amp;n&gt;8&quot; onmouseout='if(n&gt;5)alert(\'True\');else alert(&quot;False&quot;)'&gt; not this &lt;br&gt;
Matches
&lt;input type=button onclick='n&gt;5' value=test onmouseover=&quot;n&lt;5&amp;&amp;n&gt;8&quot; onm
Non-Matches
haven't found any exceptions yet
Author Rating: The rating for this expression. Toby Henderson
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
&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][^>]*\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
<[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 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
&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 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
^(?<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;[^&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
<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
&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
^[^<>`~!/@\#}$%:;)(_^{&*=|'+]+$
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
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
^(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: Not yet rated. James Fal
Title Test Details Pattern Title
Expression
<([^\s>]*)(\s[^<]*)>
Description
grab all tags attributes... &lt;img src=&quot;truc&quot;&gt; returns : &lt; (1:img) (2: src=&quot;truc&quot;) &gt; i use it to clean html pages to grab infos... use a RegEx Replace with &quot;&lt;$1&gt;&quot; to keep only tags codes...
Matches
<img src="truc"> | <body background='...'> | <p align='left'>
Non-Matches
<br> | </body> | <p>
Author Rating: Not yet rated. Tanguy Pruvot
Title Test Details Pattern Title
Expression
<([^<>\s]*)(\s[^<>]*)?>
Description
All tags in first submatche All attributes in second one...
Matches
<td class="TD2"> | <!-- comment --> | </table>
Non-Matches
19-Fev-2002 - 19h00 | New Changes : | ...
Author Rating: Not yet rated. Tanguy Pruvot
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
(\[(\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
Change page:   |    Displaying page 2 of 4 pages; Items 21 to 40

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