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 2 of 4 pages; Items 21 to 40
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 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: The rating for this expression. James Fal
Title Test Details Pattern Title
Expression
&(?![a-zA-Z]{2,6};|#[0-9]{3};)
Description
The goal of this regular expression is to replace all & (ampersand) characters by & 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
&ThisIsTooLong; | Lilo & Stich | &l;
Non-Matches
< | ¦ | ¦
Author Rating: The rating for this expression. Frederick Samson
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 Pattern Title
Expression
<(\/{0,1})img(.*?)(\/{0,1})\>
Description
This regular expression allows you to match all image tags
Matches
<img src="immy.jpg" alt="Image"> | <img src="immy.jpg" alt=&q
Non-Matches
< img >
Author Rating: The rating for this expression. Alessandro Pellegrini
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 (&) 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; | © | '
Non-Matches
& | &#Hello; | &#Xray;
Author Rating: The rating for this expression. Michael Ash
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: The rating for this expression. Ashish Sheth
Title Test Details Pattern Title
Expression
<(?:[^"']+?|.+?(?:"|').*?(?:"|')?.*?)*?>
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 "<>". It will match all these <hr size="3" noshade color="#000000" align="left"> <p style="margin-top:0px;margin-bottom:0px" align="center"><font face="Times New Roman" size="5"><b>UNITED STATES</b></font></p> <input type=button onclick='if(n.value>5)do_this();'> not this <br> <input type=button onclick="n>5?a():b();" value=test> not this <br> <input type=button onclick="n>5?a(\"OK\"):b('Not Ok');" value=test> not this <br> <input type=button onclick='n>5' value=test onmouseover="n<5&&n>8" onmouseout='if(n>5)alert(\'True\');else alert("False")'> not this <br>
Matches
<input type=button onclick='n>5' value=test onmouseover="n<5&&n>8" onm
Non-Matches
haven't found any exceptions yet
Author Rating: The rating for this expression. Toby Henderson
Title Test Details Pattern Title
Expression
\xA9
Description
Matches the copyright symbol (©). Pretty simple, yet I dont think existed on RegExLib before.
Matches
©
Non-Matches
anything
Author Rating: The rating for this expression. Roman Lukyanenko
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: The rating for this expression. Lewis Moten
Title Test Details Pattern Title
Expression
<[^>]*>
Description
HTML Pattern Matching PLEASE HELP /&lt;[^&gt;]*&gt;/ig The above pattern is only successful when html tag are simple (they don't include any javascript). This mean that the pattern will fail if something like this is within the tag &lt;input type=button value=test onclick='if(n.value&gt;5)do_this();'&gt;. It will not match the entire open n close sign. How do you write a pattern that will pass all these tag so that the pattern will match from the open to the close sign and not when it just see a &gt; within a '' or &quot;&quot;. &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; Any help would be greatly appreciate. Thanks a whole lot. Logan
Matches
<html>
Non-Matches
abc
Author Rating: The rating for this expression. Logan Tran
Title Test Details Pattern Title
Expression
(?i:)(?&lt;=\.)\D\D(?:-\D{2,3}?(?:-\D\D\D\D)?)?(?=.resx) #Just change the extension if you want to take a Culture out of different type of file name. #The result will always be of the format: #(2CharacterLanguage)-(2or3CharacterLocale)-(4CharacterScript) #where the second or third set are optional #this matches the format of the CultureInfo object in Microsoft .NET
Description
This expression pulls the Culture name out of a .resx file name.
Matches
blah.is.en.resx | something.zh-CHS.resx | something.uz-UZ-Cyrl.resx
Non-Matches
blah.is.eee.resx | something.zh-X.resx | something.uz-UZ-Uz.resx
Author Rating: The rating for this expression. Eric Falsken
Title Test Details Pattern Title
Expression
href[ ]*=[ ]*('|\&quot;)([^\&quot;'])*('|\&quot;)
Description
the regex's on this site for pulling links off a page always seemed to be faulty, or at least never worked with PHP, so i made this one. simple, as i'm an amateur with regex's, but stumbled thru it and this one actually works. tested with PHP function: preg_match_all(&quot;/href[ ]*=[ ]*('|\&quot;)([^\&quot;'])*('|\&quot;)/&quot;,$string,$matches)
Matches
href=&quot;index.php&quot; | href = 'http://www.dailymedication.com' | href = &quot;irc://irc.junk
Non-Matches
href=http://www.dailymedication.com
Author Rating: The rating for this expression. Jason Paschal
Title Test Details Pattern Title
Expression
/\*[\d\D]*?\*/
Description
If you need to extract or remove any /* */ sytle comments from any Java, JavaScript, C, C++, CSS, etc code you have this regular expression can help.
Matches
/* my comment */ | /* my multiline comment */ | /* my nested comment */
Non-Matches
*/ anything here /* | anything between 2 seperate comments | \* *\
Author Rating: The rating for this expression. Chris Craft
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
src[^&gt;]*[^/].(?:jpg|bmp|gif)(?:\&quot;|\')
Description
This expression will return the src (source) property of an image tag &lt;IMG&gt;. The source returned is limited to the file extensions supplied. It doesn't matter if the image is prefixed with '../' or 'http://..blah' or 'drive\path' or nothing. This expression could be modifed to return other sources or for the tags (ie &lt;BGSOUND&gt;, &lt;SCRIPT&gt;, etc.) depending on the file extensions given. I needed this to replace the source of images in a HTML page when I wanted to save the page to a local drive and keep the images intact. If anybody could modify this further to include only the &lt;IMG&gt; tag, I would appreciate the effort.
Matches
src=&quot;../images/image.jpg&quot; | src=&quot;http://domain.com/images/image.jpg&quot; | src='d:\w
Non-Matches
src=&quot;../images/image.tif&quot; | src=&quot;cid:value&quot;
Author Rating: The rating for this expression. Lloyd Sturge
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
>(?:(?<t>[^<]*))
Description
Detects HTML tags open and/or closed with and without whitespace or characters in between. Good for stripping all tags from a string.
Matches
<b> | </b> | <p><b>some text</b></p>
Non-Matches
<
Author Rating: The rating for this expression. Jonathan Crossland
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: The rating for this expression. Mladen Mihajlovic
Title Test Details Pattern Title
Expression
^\s*-?(\d*\.)?([0-2])?[0-9]:([0-5])?[0-9]:([0-5])?[0-9](\.[0-9]{1,7})?\s*$
Description
This should be the pattern described in the documentation for the .NET TimeSpan.Parse method - generally parses time spans. From the .NET docs: public static TimeSpan Parse(string s); The s parameter contains a specification of the form: [ws][-][d.]hh:mm:ss[.ff][ws] Items in square brackets ([ and ]) are optional, colons and periods (: and .) are literal characters, and other items are as follows. Item Description ws optional white space &quot;-&quot; optional minus sign indicating a negative time &quot;d&quot; optional days &quot;hh&quot; hours, ranging from 0 to 23 &quot;mm&quot; minutes, ranging from 0 to 59 &quot;ss&quot; seconds, ranging from 0 to 59 &quot;ff&quot; optional fractional seconds, from 1 to 7 decimal digits
Matches
10:12:34 | 932323.9:00:32.3420
Non-Matches
10:20:80
Author Rating: The rating for this expression. Philipp Schumann
Change page:   |    Displaying page 2 of 4 pages; Items 21 to 40

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