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 Pattern Title
Expression
src[^>]*[^/].(?:jpg|bmp|gif)(?:\"|\')
Description
This expression will return the src (source) property of an image tag <IMG>. 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 <BGSOUND>, <SCRIPT>, 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 <IMG> tag, I would appreciate the effort.
Matches
src="../images/image.jpg" | src="http://domain.com/images/image.jpg" | src='d:\w
Non-Matches
src="../images/image.tif" | src="cid:value"
Author Rating: The rating for this expression. Lloyd Sturge
Title Test Details Pattern Title
Expression
%[\-\+0\s\#]{0,1}(\d+){0,1}(\.\d+){0,1}[hlI]{0,1}[cCdiouxXeEfgGnpsS]{1}
Description
This regular expression matches "c" format strings for printf/scanf functions.
Matches
%s%02d | %s | %04lX
Non-Matches
%5.f | %++X | %@d
Author Rating: The rating for this expression. Vladimir Klykov
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
(?mi:(?<=^(([^'"\n])|("[^"]*"))*[\t ])_(?=\s*$))
Description
looks for line concantenation character &quot;_&quot; in vb/vb.net source files. 1) It must be preceded by at least one space or tab. 2) It must be at the end of the line (okay if followed by whitespace) 3) And it must not be in commented code Used expression at http://www.regexlib.com/REDetails.aspx?regexp_id=371 for inspiration.
Matches
<XmlAttribute("xml-att")> _ | Sub WillGetThis() _ | "will ' get this" _
Non-Matches
' Won't get this _ | Sub wontGetThis()_ | "won't get this " _ "bad code"
Author Rating: Not yet rated. Christopher Strolia-Davis
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: Not yet rated. Darren Neimke
Title Test Details Pattern Title
Expression
&lt;\*?font # Match start of Font Tag (?(?=[^&gt;]+color.*&gt;) #IF/THEN lookahead color in tag (.*?color\s*?[=|:]\s*?) # IF found THEN move ahead ('+\#*?[\w\s]*'+ # CAPTURE ColorName/Hex |&quot;+\#*?[\w\s]*&quot;+ # single or double |\#*\w*\b) # or no quotes .*?&gt; # &amp; move to end of tag |.*?&gt; # ELSE move to end of Tag ) # Close the If/Then lookahead # Use Multiline and IgnoreCase # Replace the matches from RE with MatchEvaluator below: # if m.Groups(1).Value&lt;&gt;&quot;&quot; then # Return &quot;&lt;font color=&quot; &amp; m.Groups(1).Value &amp; &quot;&gt;&quot; # else # Return &quot;&lt;font&gt;&quot; # end if
Description
This RE and MatchEvaluator will remove everything from inside HTML font tags EXCEPT the color declaration. (For ex: allow users to upload HTML content to site without their font tags overridding the font styles set in the CSS, except for the ability to change the font color for special emphasis.) This works with color declarations using single quotes, double quotes, no quotes, color-names (red, black), Hex colors (#669933), and inline Style declarations inside a font tag. Does not work with inline Style declarations inside other tags like DIV, SPAN, or P (although it could be expanded to include those as well).
Matches
&lt;font size=5 color=black face=Arial&gt; | &lt;font style=&quot;font-family:arial;color:red&quot;&
Non-Matches
&lt;DIV style=&quot;font-family:arial;color:red&quot;&gt; | &lt;SPAN style=&quot;color:red&quot;&gt;
Author Rating: Not yet rated. Cheri Verdend
Title Test Details Pattern Title
Expression
/\*.+?\*/
Description
Searches for SQL comments within a T-SQL statement...
Matches
/* This is a T-SQL comment! */
Non-Matches
SELECT * FROM Customers
Author Rating: Not yet rated. Mike OBrien
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: Not yet rated. Philipp Schumann
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: Not yet rated. Aivar Holyfield
Title Test Details Pattern Title
Expression
^[^']*?\&lt;\s*Assembly\s*:\s*AssemblyVersion\s*\(\s*&quot;(\*|[0-9]+.\*|[0-9]+.[0-9]+.\*|[0-9]+.[0-9]+.[0-9]+.\*|[0-9]+.[0-9]+.[0-9]+.[0-9]+)&quot;\s*\)\s*\&gt;.*$
Description
Matches the AssemblyVersion attribute in an Assembly.vb file. The version value is captured.
Matches
&lt;Assembly: AssemblyVersion(&quot;1.0.*&quot;)&gt; (all version formats, i.e.: * to 1.0.0.0)
Non-Matches
'&lt;Assembly: AssemblyVersion(&quot;1.0.*&quot;)&gt; (commented lines)
Author Rating: Not yet rated. Paolo Mazzini
Title Test Details Pattern Title
Expression
(?&lt;entryname&gt;[\w_0-9]+)\s*=\s+\(\s*DESCRIPTION\s*=\s+\(\s*ADDRESS_LIST\s*=\s+\(\s*ADDRESS\s*=\s*\(\s*PROTOCOL\s*=\s*(?&lt;protocol&gt;\w+)\)\s*\(\s*HOST\s*=\s*(?&lt;host&gt;[^\)]+)\)\s*\(\s*PORT\s*=\s*(?&lt;port&gt;\d+)\s*\)\s*\)\s+\)\s+\(\s*CONNECT_DATA\s*=\s+\(\s*SERVICE_NAME\s*=\s*(?&lt;svcname&gt;\w+)\s*\)\s+\)\s+\)
Description
This regex is designed to parse entries from tnsnames.ora for Oracle connections. This is a crude first cut in that it doesn't allow for multiple ADDRESS entries in the ADDRESS_LIST section, and I don't know if there are other attributes that I should be allowing for. Basically, I just don't know enough about possible scenarios at this time, so I just wrote it to what I see in the wild where I work.
Matches
D007DEVL = (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = ddt210)(PORT =
Non-Matches
Anything that is not a tnsnames.ora entry
Author Rating: Not yet rated. Charles Farley
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: Not yet rated. Fernando Eklipse
Title Test Details Pattern Title
Expression
(?=(?:[^\']*\'[^\']*\')*(?![^\']*\'))
Description
This exp will parse out space delimited strings with consideration to single quotes. I use it with SQL statements.
Matches
BETWEEN '11/1/2004' AND '12/1/2004 11:59:59 PM'
Non-Matches
flabberguasted
Author Rating: Not yet rated. Scott Richardson
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: Not yet rated. Eric Falsken
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: Not yet rated. Chris Strolia-Davis
Title Test Details Pattern Title
Expression
href=[\&quot;\']?((?:[^&gt;]|[^\s]|[^&quot;]|[^'])+)[\&quot;\']?
Description
This will match just about everything after href= Its good if you just need a list of all the href= values
Matches
href=&quot;http://www.google.com/tsunami_relief.html&quot; | href=/preferences?hl=en | href=&quot;ht
Non-Matches
src=blah blah
Author Rating: Not yet rated. Chris Richards
Title Test Details Pattern Title
Expression
&lt;a[\s]+[^&gt;]*?href[\s]?=[\s\&quot;\']+(.*?)[\&quot;\']+.*?&gt;([^&lt;]+|.*?)?&lt;\/a&gt;
Description
This regex will extract the link and the link title for every a href in HTML source. Useful for crawling sites. Note that this pattern will also allow for links that are spread over multiple lines.
Matches
&lt;a href='http://www.regexlib.com'&gt;Text&lt;/a&gt; | &lt;a href=&quot;...&quot;&gt;Text&lt;/a&gt
Non-Matches
all other html tags
Author Rating: Not yet rated. Jacek Sompel
Title Test Details Pattern Title
Expression
(^[a-zA-Z][a-zA-Z0-9_]*)|(^[_][a-zA-Z0-9_]+)
Description
This pattern can be used for validating a string as a valid element name (e.g. variable or class name) in Microsoft .NET. See also http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vbcn7/html/vbconelementnames.asp
Matches
var | _withunder_score99 | TeSt
Non-Matches
_ | 123abc | 9
Author Rating: Not yet rated. Howard Richards
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: Not yet rated. Jonathan Crossland
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: Not yet rated. Ed Preston
Change page:   |    Displaying page 2 of 4 pages; Items 21 to 40

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