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

Please support RegExLib Sponsors

Sponsors

Advanced Search

Keywords

Category

Minimum Rating

Results per Page

Search Results: 47 regular expressions found.

Change page:   |    Displaying page 1 of 3 pages; Items 1 to 20
Title Test Details Pattern Title
Expression
\[link="(?<link>((.|\n)*?))"\](?<text>((.|\n)*?))\[\/link\]
Description
This can be used in conjunction with the replace method to provide pseudo-code support without having to enable HTML. The replacement string (in ASP.NET, use RegExp.Replace(SourceString, RegularExpressionPattern, ReplacementString) is &lt;a href=&quot;${link}&quot;&gt;${text}&lt;/a&gt;.
Matches
[link="http://www.yahoo.com"]Yahoo[/link]
Non-Matches
[link]http://www.yahoo.com[/link] | [link=http://www.yahoo.com]Yahoo[/link]
Author Rating: Not yet rated. Ryan S
Title Test Details Pattern Title
Expression
((&quot;|')[a-z0-9\/\.\?\=\&amp;]*(\.htm|\.asp|\.php|\.jsp)[a-z0-9\/\.\?\=\&amp;]*(&quot;|'))|(href=*?[a-z0-9\/\.\?\=\&amp;&quot;']*)
Description
Will locate an URL in a webpage. It'll search in 2 ways - first it will try to locate a href=, and then go to the end of the link. If there is nu href=, it will search for the end of the file instead (.asp, .htm and so on), and then take the data between the &quot;xxxxxx&quot; or 'xxxxxx'
Matches
href=&quot;produktsida.asp?kategori2=218&quot; | href=&quot;NuclearTesting.htm&quot;
Non-Matches
U Suck
Author Rating: Not yet rated. Henric Rosvall
Title Test Details Pattern Title
Expression
(\[[Ii][Mm][Gg]\])(\S+?)(\[\/[Ii][Mm][Gg]\])
Description
easy when you want to allow your users to post images, but in a controlled way. I used it like this (in php): $text = preg_replace(&quot;/(\[IMG\])(\S+?)(\[\/IMG\])/is&quot;, &quot;&lt;a href=\&quot;\\2\&quot; target=\&quot;_blank\&quot;&gt;&lt;IMG SRC=\&quot;\\2\&quot; align=\&quot;center\&quot; height=\&quot;100\&quot; border=\&quot;0\&quot;&gt;&lt;/a&gt;&quot;,$text); so whenever they use [img]http://www.foo.com/bleh.jpg[/img] it will be converted to &lt;a href=&quot;http://www.foo.com/bleh.jpg&quot; target=&quot;_blank&quot;&gt;&lt;IMG SRC=&quot;http://www.foo.com/bleh.jpg&quot; align=&quot;center&quot; height=&quot;100&quot; border=&quot;0&quot;&gt;&lt;/a&gt; so you get a 100 pixels high picture, and when they click on it it opens in a new window... (to prevent users from posting huge pictures and stuff)
Matches
[IMG]http://bleh.jpg[/IMG] | [ImG]bleh[/imG] | [img]ftp://login:pass@bleh.gif[/img]
Non-Matches
&lt;img src=&quot;bleh.jpg&quot;&gt;
Author Rating: The rating for this expression. marnik vander elst
Title Test Details Pattern Title
Expression
(mailto\:|(news|(ht|f)tp(s?))\://)(([^[:space:]]+)|([^[:space:]]+)( #([^#]+)#)?)
Description
this is a very little regex for use within a content management software. links within textfields has not to be written in html. the editor of the cms is instructed to use it like this: 1. mention spaces in front and behind the url 2. start url with http://, mailto://, ftp:// ... 3. use optional linktext within #linktext# (separated with single space) 4. if there is no linktext the url/email will show up as linktext 5. avoid url with spaces in filename (use %20 urldecode) replace pattern (space in front): &lt;a href=&quot;\\1\\3\\4&quot; target=&quot;_blank&quot;&gt;\\3\\6&lt;/a&gt;
Matches
http://www.domain.com | http://www.domain.com/index%20page.htm #linktext# | mailto://user@domai
Non-Matches
&lt;a href=&quot;http://www.domain.com&quot;&gt;real html link&lt;/a&gt; | http://www.without_space_
Author Rating: Not yet rated. Martin Schwedes
Title Test Details Pattern Title
Expression
^[A-Za-zÀ-ÖØ-öø-ÿ '\-\.]{1,22}$
Description
Should match just about any real name, either first name or last name -- even Jill St. John. Can't think of a name that has more than 22 characters. My home page: &lt;A HREF=&quot;http://www.US-Webmasters.com/best-start-page/&quot;&gt;http://www.US-Webmasters.com/best-start-page/&lt;/A&gt;
Matches
Jill St. John | Jørnç | Mc O'Donald-Öztürk
Non-Matches
abc123 | Nobody! | @#$%^&
Author Rating: Not yet rated. W. D.
Title Test Details Pattern Title
Expression
href=[\"\'](http:\/\/|\.\/|\/)?\w+(\.\w+)*(\/\w+(\.\w+)?)*(\/|\?\w*=\w*(&\w*=\w*)*)?[\"\']
Description
I wrote up this regular expression to fetch the href attribute found in &lt;a&gt; tags as well as a few other HTML tags.
Matches
href="www.yahoo.com" | href="http://localhost/blah/" | href="eek"
Non-Matches
href="" | href=eek | href="bad example"
Author Rating: The rating for this expression. Andrew Lee
Title Test Details Pattern Title
Expression
(\s|\n|^)(\w+://[^\s\n]+)
Description
will match free floating valid protocol + urls in text ... will not touch the ones wrapped in a tag, so that you can auto-link the ones that aren't :) couple of things to know : 1. if the url is next to a tag this won't work (eg : &lt;br&gt;http://www.acme.com), the url must either start with a \s, \n or any character other than &gt;. 2. the pattern will match the preceding \s and \n too, so when you replace put them back in place $1 will either be \s or \n, $2 will be the exact match vb usage : set re = New RegExp re.Pattern =&quot;(\s|\n|^)(\w+://[^\s\n]+)&quot; strResult = re.Replace(strText, &quot;$1&lt;a href='$2' target='_new'&gt;$2&lt;/a&gt;&quot;)
Matches
http://www.acme.com | ftp://ftp.acme.com/hede | gopher://asdfasd.asdfasdf
Non-Matches
&lt;a href=&quot;http://acme.com&quot;&gt;http://www.acme.com&lt;/a&gt; | &lt;br&gt;http://www.acme.
Author Rating: The rating for this expression. ic onur
Title Test Details email address (RFC 2822 mailbox)
Expression
^((?>[a-zA-Z\d!#$%&'*+\-/=?^_`{|}~]+\x20*|"((?=[\x01-\x7f])[^"\\]|\\[\x01-\x7f])*"\x20*)*(?<angle><))?((?!\.)(?>\.?[a-zA-Z\d!#$%&'*+\-/=?^_`{|}~]+)+|"((?=[\x01-\x7f])[^"\\]|\\[\x01-\x7f])*")@(((?!-)[a-zA-Z\d\-]+(?<!-)\.)+[a-zA-Z]{2,}|\[(((?(?<!\[)\.)(25[0-5]|2[0-4]\d|[01]?\d?\d)){4}|[a-zA-Z\d\-]*[a-zA-Z\d]:((?=[\x01-\x7f])[^\\\[\]]|\\[\x01-\x7f])+)\])(?(angle)>)$
Description
This accepts RFC 2822 email addresses in the form:<br> blah@blah.com OR<br> Blah &lt;blah@blah.com&gt;<br> <br> RFC 2822 email 'mailbox':<br> mailbox = name-addr | addr-spec<br> name-addr = [display-name] "<" addr-spec ">"<br> addr-spec = local-part "@" domain<br> domain = rfc2821domain | rfc2821domain-literal<br> <br> local-part conforms to RFC 2822.<br> <br> domain is either:<br> An rfc 2821 domain (EXCEPT that the final sub-domain must consist of 2 or more letters only).<br> OR<br> An rfc 2821 address-literal.<br> (Note, no attempt is made to fully validate an IPv6 address-literal.)<br> <br> Notes:<br> This pattern uses (.NET/Perl only?) features named group "(?&lt;name&gt;)" and alternation/IF (?(name)).<br> <br> See <a href="http://regexadvice.com/forums/permalink/26742/26742/ShowThread.aspx#26742">this regexadvice.com thread</a> for more info, including a version that does not use .NET features.<br> <br> RFC 2822 (and 822) do allow embedded comments, whitespace, and newlines within *some* parts of an email address, but this pattern above DOES NOT.<br> <br> RFC 2822 (and 822) allow the domain to be a simple domain with NO ".", but this pattern requires a compound domain at least one "." in the domain name, as per RFC 2821 (4.1.2).<br> <br> RFC 2822 allows/disallows certain whitespace characters in parts of an email address, such as TAB, CR, LF BUT the pattern above does NOT test for these, and assumes that they are not present in the string (on the basis that these characters are hard to enter into an edit box).
Matches
name.surname@blah.com | Name Surname <name.surname@blah.com> | "b. blah"@blah.co.nz
Non-Matches
name surname@blah.com | name."surname"@blah.com | name@bla-.com
Author Rating: The rating for this expression. Mark Cranness
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
href[\s]*=[\s]*&quot;[^\n&quot;]*&quot;
Description
A very short pattern for extracting hrefs from HTML, does not validate they are within a tag
Matches
href =&quot;http://www.theregister.com/&quot; | href=&quot;http://theregister.co.uk&quot; | hre
Non-Matches
href=http://theregister.co.uk
Author Rating: Not yet rated. Tony Hawe
Title Test Details Pattern Title
Expression
&lt;\s*a\s[^&gt;]*\bhref\s*=\s* ('(?&lt;url&gt;[^']*)'|&quot;&quot;(?&lt;url&gt;[^&quot;&quot;]*)&quot;&quot;|(?&lt;url&gt;\S*))[^&gt;]*&gt; (?&lt;body&gt;(.|\s)*?)&lt;\s*/a\s*&gt;
Description
Suitable for extraction of all hyperlinks in the format: &lt;a ... href=&quot;...&quot; ...&gt; some text &lt;/a&gt; from a text document. Separates in groups the components of the links (url and body).
Matches
&lt;a href=&quot;javascript:'window.close()'&quot;&gt;close the window&lt;/a&gt; | &lt;a target=&quo
Non-Matches
&lt;aa href=&quot;test.htm&quot;&gt;test&lt;/a&gt; | &lt; a href hr = 'http://www.nakov.com'&gt;...&
Author Rating: The rating for this expression. Svetlin Nakov
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
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;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
(((file|gopher|news|nntp|telnet|http|ftp|https|ftps|sftp)://)|(www\.))+(([a-zA-Z0-9\._-]+\.[a-zA-Z]{2,6})|([0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}))(/[a-zA-Z0-9\&amp;%_\./-~-]*)?
Description
You can use this regular expression in your PHP scripts to convert entered URL in text to URL link. Example: $text=ereg_replace(&quot;(((file|gopher|news|nntp|telnet|http|ftp|https|ftps|sftp)://)|(www\.))+(([a-zA-Z0-9\._-]+\.[a-zA-Z]{2,6})|([0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}))(/[a-zA-Z0-9\&amp;%_\./-~-]*)?&quot;,&quot;&lt;a href=\&quot;./redir.php?url=\\0\&quot; target=\&quot;_blank\&quot;&gt;\\0&lt;/a&gt;&quot;,$text);
Matches
http://diskusneforum.sk | www.diskusneforum.sk | ftp://123.123.123.123/
Non-Matches
diskusneforum.sk
Author Rating: The rating for this expression. Martin Ille
Title Test Details Pattern Title
Expression
&lt;a[a-zA-Z0-9 =&quot;'.:;?]*(name=){1}[a-zA-Z0-9 =&quot;'.:;?]*\s*((/&gt;)|(&gt;[a-zA-Z0-9 =&quot;'&lt;&gt;.:;?]*&lt;/a&gt;))
Description
This expression matches only valid html anchors. Those are anchors with an attribute name=. Such anchor can be closed either with &lt;/a&gt; or with /&gt;. If someone can help - one thing still missing is not matching html tags with parameter href, becazse such should be considered as non valid anchors.
Matches
&lt;a name=&quot;anchorName&quot;&gt;Anchor&lt;/a&gt; | &lt;a name=anchorName /&gt;
Non-Matches
&lt;a href=&quot;somewhere&quot;&gt; | &lt;a href&gt; | &lt;a name /&gt;
Author Rating: The rating for this expression. Aleš Potocnik
Title Test Details Pattern Title
Expression
&lt;a[a-zA-Z0-9 =&quot;'.?_/]*(href\s*=\s*){1}[a-zA-Z0-9 =&quot;'.?_/]*\s*((/&gt;)|(&gt;[a-zA-Z0-9 =&quot;'&lt;&gt;.?_/]*&lt;/a&gt;))
Description
An expression that matches all XHTML valid hrefs (links). It even alows spaces like href = &quot;href...&quot;, dough this is not quite XHTML valid. It finds only hrefs but not for instance anchors. If you need to find only anchors, replace &quot;href&quot; within expression with &quot;name&quot; and thats it.
Matches
&lt;a href=&quot;www.google.com&quot;&gt;Google&lt;/a&gt; | &lt;a href=www.google.com /&gt; | &lt;a
Non-Matches
&lt;a name=&quot;anchor&quot;&gt;Anchor&lt;/a&gt; | &lt;img src=&quot;image.gif&quot;&gt;
Author Rating: The rating for this expression. Aleš Potocnik
Title Test Details Pattern Title
Expression
\b((?#optional port)(https?|ftp|file)://)? (?#sub domain)([a-z0-9](?:[-a-z0-9]*[a-z0-9])?\.)+ (?#top domain)(com\b|edu\b|biz\b|gov\b|in(?:t|fo)\b|mil\b|net\b|org\b|[a-z][a-z]\b) (?#optional port)(:\d+)? (?#optional path)(/[-a-z0-9_:\@&amp;?=+,.!/~*'%\$]*)* (?#not ending in)(?&lt;![.,?!]) (?#not enclosed in)(?!((?!(?:&lt;a )).)*?(?:&lt;/a&gt;)) (?#or enclosed in)(?!((?!(?:&lt;!--)).)*?(?:--&gt;))
Description
Yet Another URL Search. Useful for capturing URLs in raw text. Ignores URLs in HREF and comments. Turn off whitespacing to test!
Matches
http://www.google.com | google.com | http://some-domain.net/very/long/path/123.html
Non-Matches
subdomain.NonExistentTopDomain | &lt;a href=&quot;http://www.google.com&quot;&gt;www.google.com&lt;/
Author Rating: Not yet rated. Simon Ferguson
Title Test Details Pattern Title
Expression
&lt;a.*?href=(.*?)(?((?:\s.*?)&gt;.*?&lt;/a&gt;)(?:(?:\s.*?)&gt;(.*?)&lt;/a&gt;)|(?:&gt;(.*?)&lt;/a&gt;))
Description
this Expression use conditional expression to eveluate parameter after &quot;HREF&quot; and executes the yes/no part of the expression. this expression finds &lt;A&gt; TAG and returns value of &quot;HREF&quot; and the value hold in between &lt;a&gt;&lt;/a&gt; tags. the expression returns maximum 3 sub matches. the first match returns the &quot;HREF&quot; tag value and rest of two holds the value of the tag alternativly. so after executing the expression you need to itarate through all the submatches and need to find out non NULL tags to get value. the output of the above matching expamples would be like this : 1: &quot;/url?sa=p&amp;pref=ig&amp;pval=2&amp;q=http://www.google.co.in/ig%3Fhl%3Den&quot; 2:[Personalized Home] 3:[] or NULL the output of the second matching example would be like this. 1:/advanced_search?hl=en 2:[] or NULL 3:[Advanced Search]
Matches
&lt;a href=&quot;/url?sa=p&amp;pref=ig&amp;pval=2&amp;q=http://www.google.co.in/ig%3Fhl%3Den&quot; o
Non-Matches
none
Author Rating: The rating for this expression. himraj love
Title Test Details Pattern to find Anchor Tag in a web page
Expression
<a[\s]+[^>]*?href[\s]?=[\s\"\']*(.*?)[\"\']*.*?>([^<]+|.*?)?<\/a>
Description
This pattern is a slight modification in pattern submitted by Jacek Sompel. Using this tag one can also match anchor tags not having ' (single quote) or " (double quote) in href. This is useful for web crawler for crawling all links in a web page.
Matches
&lt;a href='http://www.regexlib.com'&gt;Text&lt;/a&gt; | &lt;a href="..."&gt;Text&lt;/a&gt; | &lt;a href=http://www.regexlib.com&gt;Text&lt;/a&gt;
Non-Matches
all other html tags
Author Rating: Not yet rated. Kuleen Upadhyaya
Change page:   |    Displaying page 1 of 3 pages; Items 1 to 20

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