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: 83 regular expressions found.

Change page:   |    Displaying page 1 of 5 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
(http|ftp|https):\/\/[\w\-_]+(\.[\w\-_]+)+([\w\-\.,@?^=%&amp;:/~\+#]*[\w\-\@?^=%&amp;/~\+#])?
Description
*CORRECTED: Again thanks for all the comments below. If you want to include internal domain as well change the partial code (\.[\w-_]+)+ to (\.[\w-_]+)? See the comments below* This is the regular expression I use to add links in my email program. It also ignores those suppose-to-be commas/periods/colons at the end of the URL, like this sentence &quot;check out http://www.yahoo.com/.&quot; (the period will be ignored) Note that it requires some modification to match ones that dont start with http.
Matches
http://regxlib.com/Default.aspx | http://electronics.cnet.com/electronics/0-6342366-8-8994967-1.html
Non-Matches
www.yahoo.com
Author Rating: The rating for this expression. M H
Title Test Details Pattern Title
Expression
^(http|https|ftp)\://[a-zA-Z0-9\-\.]+\.[a-zA-Z]{2,3}(:[a-zA-Z0-9]*)?/?([a-zA-Z0-9\-\._\?\,\'/\\\+&amp;%\$#\=~])*[^\.\,\)\(\s]$
Description
This Regex (can be used e.g. in PHP with eregi) will match any valid URL. Unlike the other exapmles here, it will NOT match a valid URL ending with a dot or bracket. This is important if you use this regex to find and &quot;activate&quot; Links in an Text
Matches
https://www.restrictd.com/~myhome/
Non-Matches
http://www.krumedia.com. | (http://www.krumedia.com) | http://www.krumedia.com,
Author Rating: Not yet rated. Michael Krutwig
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
^&lt;a\s+href\s*=\s*&quot;http:\/\/([^&quot;]*)&quot;([^&gt;]*)&gt;(.*?(?=&lt;\/a&gt;))&lt;\/a&gt;$
Description
Regexp to find all external links in a HTML string. Can easily be modified to handle all/other links/protocols (like file/https/ftp). Uses lookahead assertions and non-greedy modifier to check for the end &lt;/a&gt; but still allow html tags inbetween start and end A tag. Takes into account that there could be linebreaks and other nasty whitespace chars in the middle of the tag. I am using it to find all external links in embedded HTML code and change 1.the target of the link 2.insert a &quot;Leaving Site&quot; logo to illustrate you are leaving site.
Matches
&lt;a href=&quot;http://www.mysite.com&quot;&gt;my external link&lt;/a&gt; | &lt;a href=&quot;http:/
Non-Matches
&lt;a href=&quot;myinternalpage.html&quot;&gt;my internal link&lt;/a&gt;
Author Rating: Not yet rated. Anders Rask
Title Test Details Pattern Title
Expression
&lt;[aA][ ]{0,}([a-zA-Z0-9&quot;'_,.:;!?@$&amp;()%=/ ]|[-]|[ \f]){0,}&gt;((&lt;(([a-zA-Z0-9&quot;'_,.:;!?@$&amp;()%=/ ]|[-]|[ \f]){0,})&gt;([a-zA-Z0-9&quot;'_,.:;!?@$&amp;()%=/ ]|[-]|[ \f]){0,})|(([a-zA-Z0-9&quot;'_,.:;!?@$&amp;()%=/ ]|[-]|[ \f]){0,})){0,}
Description
I wrote this sweet little (well, not so little really) reg to extract links from an HTML source.... it is very robust, give it a try. The only limitation I have discovered is that it can't match invalid HTML...
Matches
&lt;a href='javascript:functionA();'&gt;&lt;i&gt;this text is italicized&lt;/i&gt;&lt;/a&gt;
Non-Matches
&lt;A href='#'&gt;&lt;P&lt;/A&gt;&lt;/P&gt;
Author Rating: Not yet rated. Brian Webb
Title Test Details Pattern Title
Expression
\b(((\S+)?)(@|mailto\:|(news|(ht|f)tp(s?))\://)\S+)\b
Description
Whilst writing a plain-text to HTML function, I ran into the problem of links that users had written with &amp;lt;a&amp;gt; tags (as opposed to just writing the URL) were linking improperly. This regular expression returns many types of URL, and preceding characters, if any. This allows you to handle each type of match appropriately
Matches
href='http://www.deepart.org' | [email protected] | ftp://123.123.123.123
Non-Matches
www.deepart.org | deepart.org | 123.123.123.123
Author Rating: Not yet rated. Demo Gorgon
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 U.S. Street Address
Expression
^(?n:(?<address1>(\d{1,5}(\ 1\/[234])?(\x20[A-Z]([a-z])+)+ )|(P\.O\.\ Box\ \d{1,5}))\s{1,2}(?i:(?<address2>(((APT|B LDG|DEPT|FL|HNGR|LOT|PIER|RM|S(LIP|PC|T(E|OP))|TRLR|UNIT)\x20\w{1,5})|(BSMT|FRNT|LBBY|LOWR|OFC|PH|REAR|SIDE|UPPR)\.?)\s{1,2})?)(?<city>[A-Z]([a-z])+(\.?)(\x20[A-Z]([a-z])+){0,2})\, \x20(?<state>A[LKSZRAP]|C[AOT]|D[EC]|F[LM]|G[AU]|HI|I[ADL N]|K[SY]|LA|M[ADEHINOPST]|N[CDEHJMVY]|O[HKR]|P[ARW]|RI|S[CD] |T[NX]|UT|V[AIT]|W[AIVY])\x20(?<zipcode>(?!0{5})\d{5}(-\d {4})?))$
Description
captures US street address. Address format: ##### Street 2ndunit City, ST zip+4 address1 - must have street number and proper case street name. no punctuation or P.O Box #### punctuation manditory for P.O. address2 - optional secondary unit abbr. Secondary range required for some units. City - Proper case city name. State - State abbreviation. All caps zip - zip+4. Can't be all zeroes Abbreviations for secondary units and States are those used by the US Postal Service. http://www.usps.com/ncsc/lookups/usps_abbreviations.html Certain secondary units require a secondary range, see the above link THis RE isn't unbreakable, Probably will allow some false positives but should work for most addresses.
Matches
123 Park Ave Apt 123 New York City, NY 10002 | P.O. Box 12345 Los Angeles, CA 12304
Non-Matches
123 Main St | 123 City, State 00000 | 123 street city, ST 00000
Author Rating: The rating for this expression. Michael Ash
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> [email protected] OR<br> Blah &lt;[email protected]&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
[email protected] | Name Surname <[email protected]> | "b. blah"@blah.co.nz
Non-Matches
name [email protected] | name."surname"@blah.com | [email protected]
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
&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*href=(.*?)[\s|&gt;]
Description
Retrieves all anchor links in a html document, useful for spidering. You will need to do a replace of &quot; and ' after the regular expression, as the expression gets all links. As far as I know there is no way, even with \1 groupings, of getting a condition on whether the link contains a &quot;,' or nothing at all (&quot; and ' is easy enough, but what happens if the link starts with &quot;, and has a javascript function call with a string in it). If there is, it's probably quicker to do it like this and do a string replace anyway.
Matches
&lt;a href=&quot;http://www.blah.com&quot;&gt; | &lt;a href='../blah.html' target=&quot;_top&quot;&a
Non-Matches
&lt;a href = http://www.idiothtmlprogrammers.com &gt;
Author Rating: The rating for this expression. chris s
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
(?&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;a\s*.*?href\s*=\s*['&quot;](?!http:\/\/).*?&gt;(.*?)&lt;\/a&gt;
Description
Finds all local links, but doesnt match on external links. Use replace with $1 to leave the link text but remove the link.
Matches
&lt;a href='locallink.htm'&gt;my local link&lt;/a&gt; | &lt;a title='click here' href=&quot;/a/local
Non-Matches
&lt;a href='http://www.site.com/page.htm'&gt;www.site.com&lt;/a&gt; | &lt;a href='http://www.site.co
Author Rating: Not yet rated. james mountain
Title Test Details Pattern Title
Expression
href\s*=\s*(?:(?:\&quot;(?&lt;url&gt;[^\&quot;]*)\&quot;)|(?&lt;url&gt;[^\s*] ))&gt;(?&lt;title&gt;[^&lt;]+)&lt;/\w&gt;
Description
finds the url and url description for all links in a given text.
Matches
&lt;td bgcolor=&quot;#ffffff&quot; class=&quot;small&quot;&gt;&amp;nbsp;&lt;A HREF=&quot; http://
Non-Matches
&lt;td bgcolor=&quot;#ffffff&quot; class=&quot;small&quot;&gt;&amp;nbsp;&lt;A HREF http://www.thepla
Author Rating: Not yet rated. Matt Bruce
Title Test Details Pattern Title
Expression
((http\://|https\://|ftp\://)|(www.))+(([a-zA-Z0-9\.-]+\.[a-zA-Z]{2,4})|([0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}))(/[a-zA-Z0-9%:/-_\?\.'~]*)?
Description
This RE matches the web links which begin http://, ftp://, https:// or www. You can edit this disadvantage easy...
Matches
www.diskusneforum.sk | http://diskusneforum.sk | ftp://23.45.267.189/
Non-Matches
diskusneforum.sk | localhost
Author Rating: Not yet rated. Martin Ille
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
Change page:   |    Displaying page 1 of 5 pages; Items 1 to 20

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