63 regular expressions found in this category!
Displaying page
of
pages;
Items to
Title |
Test
Details
Pattern Title
|
Expression |
("[^"]*")|('[^\r]*)(\r\n)? |
Description |
Will match a VBScript string and/or comment
Ex:
' userinfo
strUsername = "tomsve"
iAge = 20
' temp
strPassword = "halloj"
...Would result in the following matches:
' userinfo
"tomsve"
' temp
"halloj"
Good luck!
Tom S. [email protected] |
Matches |
"my string" | "a string with ' in it" | ' comment |
Non-Matches |
asd " |
Author |
Rating:
Tom Svensson
|
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:
Michael Ash
|
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:
luca milan
|
Title |
Test
Details
Pattern Title
|
Expression |
(?mi:(?<=^(([^'"\n])|("[^"]*"))*[\t ])_(?=\s*$)) |
Description |
looks for line concantenation character "_" 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 |
<\*?font # Match start of Font Tag
(?(?=[^>]+color.*>) #IF/THEN lookahead color in tag
(.*?color\s*?[=|:]\s*?) # IF found THEN move ahead
('+\#*?[\w\s]*'+ # CAPTURE ColorName/Hex
|"+\#*?[\w\s]*"+ # single or double
|\#*\w*\b) # or no quotes
.*?> # & move to end of tag
|.*?> # 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<>"" then
# Return "<font color=" & m.Groups(1).Value & ">"
# else
# Return "<font>"
# 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 |
<font size=5 color=black face=Arial> | <font style="font-family:arial;color:red"& |
Non-Matches |
<DIV style="font-family:arial;color:red"> | <SPAN style="color:red"> |
Author |
Rating:
Not yet rated.
Cheri Verdend
|
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 |
/\*.+?\*/ |
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
"-" optional minus sign indicating a negative time
"d" optional days
"hh" hours, ranging from 0 to 23
"mm" minutes, ranging from 0 to 59
"ss" seconds, ranging from 0 to 59
"ff" 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 |
(?<HTML><a[^>]*href\s*=\s*[\"\']?(?<HRef>[^"'>\s]*)[\"\']?[^>]*>(?<Title>[^<]+|.*?)?</a\s*>) |
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:
(?<HTML><area[^>]*href\s*=\s*[\"\']?(?<HRef>[^"'>\s]*)[\"\']?[^>]*>)
(?<HTML><form[^>]*action\s*=\s*[\"\']?(?<HRef>[^"'>\s]*)[\"\']?[^>]*>)
(?<HTML><frame[^>]*scr\s*=\s*[\"\']?(?<HRef>[^"'>\s]*)[\"\']?[^>]*>)
(?<HTML><iframe[^>]*scr\s*=\s*[\"\']?(?<HRef>[^"'>\s]*)[\"\']?[^>]*>)
(?<HTML><link[^>]*href\s*=\s*[\"\']?(?<HRef>[^"'>\s]*)[\"\']?[^>]*>) |
Matches |
<a href='http://www.regexlib.com'>Text</a> | <a href="...'>Text</a> | & |
Non-Matches |
all other html tags |
Author |
Rating:
Not yet rated.
Aivar Holyfield
|
Title |
Test
Details
Pattern Title
|
Expression |
(?i:)(?<=\.)\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 |
(?<entryname>[\w_0-9]+)\s*=\s+\(\s*DESCRIPTION\s*=\s+\(\s*ADDRESS_LIST\s*=\s+\(\s*ADDRESS\s*=\s*\(\s*PROTOCOL\s*=\s*(?<protocol>\w+)\)\s*\(\s*HOST\s*=\s*(?<host>[^\)]+)\)\s*\(\s*PORT\s*=\s*(?<port>\d+)\s*\)\s*\)\s+\)\s+\(\s*CONNECT_DATA\s*=\s+\(\s*SERVICE_NAME\s*=\s*(?<svcname>\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 |
^[^']*?\<\s*Assembly\s*:\s*AssemblyVersion\s*\(\s*"(\*|[0-9]+.\*|[0-9]+.[0-9]+.\*|[0-9]+.[0-9]+.[0-9]+.\*|[0-9]+.[0-9]+.[0-9]+.[0-9]+)"\s*\)\s*\>.*$ |
Description |
Matches the AssemblyVersion attribute in an Assembly.vb file. The version value is captured. |
Matches |
<Assembly: AssemblyVersion("1.0.*")> (all version formats, i.e.: * to 1.0.0.0) |
Non-Matches |
'<Assembly: AssemblyVersion("1.0.*")> (commented lines) |
Author |
Rating:
Not yet rated.
Paolo Mazzini
|
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 "commentblock", as I like to use it with other expressions.
It avoids single line comments or inline commented code (which are not considered comment "blocks") 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=[\"\']?((?:[^>]|[^\s]|[^"]|[^'])+)[\"\']? |
Description |
This will match just about everything after href=
Its good if you just need a list of all the href= values |
Matches |
href="http://www.google.com/tsunami_relief.html" | href=/preferences?hl=en | href="ht |
Non-Matches |
src=blah blah |
Author |
Rating:
Not yet rated.
Chris Richards
|
Title |
Test
Details
Pattern Title
|
Expression |
<a[\s]+[^>]*?href[\s]?=[\s\"\']+(.*?)[\"\']+.*?>([^<]+|.*?)?<\/a> |
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 |
<a href='http://www.regexlib.com'>Text</a> | <a href="...">Text</a> |
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| ).*$|$)|"(.|"")*?") |
Description |
Pulls out comments (both Rem and ') and string literals from VB or VBScript. Usefull for spell checking or review.
Notes: The VBScript for "Rem" 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 | " This is a string with "" and ' " |
Non-Matches |
" 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
|
Displaying page
of
pages;
Items to