 |
 |
 |
 |
| YUCK!! I hate RegEx... looks like you sat on the keyboard ;o).
I am not gonna comment on the RegEx as I dont really know it well enough but for the last part you should be able to do...
"return re.IsMatch(Url);", the if statement is not really needed. |
|
 |
| Just thought of something else...
If string stuff in C# works anything like Java, then your isUrl method is doing a metric shitload of object creation. String concatenation is a killer. It would probably be better to do some cacheing of the strRegex (by making it an instance variable and and doing a 'is null' check before creating it again).
Even better would be to create the entire RegEx object in a static initilizer, but I cant say for certain that C# has them... anyone? |
|
 |
| | Here is the complete regex for URLs (warning: may cause brain to explode): [url]http://internet.ls-la.net/folklore/url-regexpr.html[url] |
|
 |
| yeah, on the final version i do create the regex strings and object as static variables, available whilst the appdomain is loaded.
if i was doing a lot of string concatenation i would use the StringBuilder class, however i dont really define that output above as 'a lot', in fact its only wrapped to make it more legible |
|
 |
| Yeah true@legible. I guess it depends how much you called it. If you used it for check emails on signups to 'tree surgeon monthly' then I guess the hit wouldnt be too great. However, use it for checking validity of every outgoing email on gmail and then you might have a problem :o).
|
|
 |
| This thing rocks, thanks!
-Malachi |
|
 |
| It's still ERROR:
Example: httpwww.com.vn
It's OK..... |
|
 |
| | I converted this to PHP's eregi . I get positives on http://hello |
|
 |
| hahahahhahaha so much code for such a simple task?
I can do the same in few lines hahahah
My site: http://freehosting1.net |
|
 |
| |
 |
| | coooooooooooooooollllllll |
|
 |
| | Concatenating constant strings does not result in any code. |
|
 |
| thats great until you get to the file/directory level:
http://www.mydomain.com/spuriousfile.---@~~~###
this validates to true... not that Im going to suggest a alternate, this one is cool :) |
|
 |
| | watch out the script is sucks |
|
 |
| this is my regexp for email validation
^[a-zA-Z0-9]+([_.-]?[a-zA-Z0-9]+)?@[a-zA-Z0-9]+([_-]?[a-zA-Z0-9]+)*([.]{1})[a-zA-Z0-9]+([.]?[a-zA-Z0-9]+)*$
im not sure its perfect
if somebody know the bug pls contact me at kopenk_3833@yahoo.co.id |
|
 |
| string strRegex = "^(https?://)"
It will fail to match http:// |
|
 |
| Well now I know where all those broken email validation pages come from.
Read the rfc, guys. rfc-822 clearly says what valid email addresses are like. Among other things, they can contain '+' characters, which none of your regexps allow.
|
|
 |
| Anonymous? Use yoyur brain,
string strRegex = "^(https?://)"
will NOT FAIL on "http://", check it before posting stupid comments :) You know regexps? So u should know what "?" means...
Peace |
|
 |
| It is good enaugh excepting 2 cases:
1. it won't match international domain name or unencoded national characters in query string (áéöä)
2. there are some urls containing double slashes and this shuld be accepted (http://www.domain.com/folder//?param=value) |
|
 |
| A possible solution for the problem mentioned above for Oracle
select * from table
where not regexp_like(webaddress,'^(https?://)?(([[:alnum:]_!~*''().&=+$%-]+: )?[[:alnum:]_!~*''().&=+$%-]+@)?(([[:digit:]]{1,3}\.){3}[[:digit:]]{1,3}|([[:alnum:]_!~*''()-]+\.)*([[:alnum:]][[:alnum:]-]{0,61})?[[:alnum:]]\.[a-z]{2,6})(:[[:digit:]]{1,4})?((/*)|(/+[[:alnum:]_!~*''().;?:@&=+$,%#-]+)+/*)$','i') |
|
 |
| And for vb.net
IsUrl = Regex.IsMatch(url, "^(https?://)?(([\w!~*'().&=+$%-]+: )?[\w!~*'().&=+$%-]+@)?(([0-9]{1,3}\.){3}[0-9]{1,3}|([\w!~*'()-]+\.)*([\w^-][\w-]{0,61})?[\w]\.[a-z]{2,6})(:[0-9]{1,4})?((/*)|(/+[\w!~*'().;?:@&=+$,%#-]+)+/*)$", RegexOptions.IgnoreCase) |
|
 |
| Thank for cool regex
dave,
http://www.onlinebizbuzz.com |
|
 |
| |
 |
| Thank you for regex !
Jos |
|
 |
| Hi... the Regex for vb.net is not working for me!
why? o_O
Regrats |
|
 |
| | Stop promoting your websites |
|
 |
| |
 |
| current:: if (!preg_match("/^(http(s?):\/\/|ftp:\/\/{1})((\w+\.){1,})\w{2,}$/i", $url))
example:: if (!preg_match('^s?https?:\/\/[-_.!~*'()a-zA-Z0-9;\/?:\@&=+\$,%#]+$', $url))
example:: if (!preg_match('^((ht|f)tp(s?)\:\/\/|~/|/)?([\w]+:\w+@)?([a-zA-Z]{1}([\w\-]+\.)+([\w]{2,5}))(:[\d]{1,5})?((/?\w+/)+|/?)(\w+\.[\w]{3,4})?((\?\w+(=\w+)?)(&\w+(=\w+)?)*)?', $url)) |
|
 |
| | sale java main tera baap batayega.... |
|
 |
| |
 |
| | Regexp is really a bonus when you are programming in soap. <a href="http://www.earthceuticals.com"> Savon naturel </ a> est faite ŕ partir d'huiles essentielles pures et les huiles végétales pures. Il n'ya pas d'animaux et pas d'ingrédients artificiels ingrédients dans <a href="http://www.earthceuticals.com"> savon naturel </ a>. |
|
 |
| This one rocks:
^(?:(?:(?i)https?(?-i):\/\/)?(?:(?:(?:25[0-5]|2[0-4][0-9]|1[0-9]{0,2})(?:\.(?:25[0-5]|2[0-4][0-9]|1[0-9]{0,2}|0)){3})|(?:[a-zA-Z0-9](?:[a-zA-Z0-9\-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9\-]{0,61}[a-zA-Z0-9])?)*)(?::(?:6[0-5]{0,2}[0-3]?[0-5]?|[1-5][0-9]{0,4}))?))(?:\/|(?:\/[^\s\x00-\x1f]+)+)?(?:(?:\?[^\s\x00-\x1f]+(?:=[^\s\x00-\x1f]+)(?:\&[^\s\x00-\x1f]+(?:=[^\s\x00-\x1f]+)?)*))?$ |
|
 |
| |
 |
| Your regexp doesn't seem to support these cases, with a (possibly blank) password:
http://user:password@host.com
http://user:@host.com
Not that I expect I'll need it myself... |
|
 |
| What about national characters? For example, this is a valid URL I think:
www.host.se/Thingyĺäö.html |
|
 |
| |
 |
| |
 |
| Thanks a lot for such a nice snippet of coding. It really helped me a lot!
<a href="http://www.transcription.su">Alex</a>
<a href="http://www.13-kadr.ru">http://www.13-kadr.ru</a> |
|
 |
| |
 |
| I was hoping to convert this so it worked a little differently, but this is my first attempt at regex, and I'm failing miserably. I need to identify and extract a specific portion of a URL via regex, of the form:
http://www.STRING_OF_INTEREST.mywebsite.com
unfortunately, I can't get my stuff to work - anyone have an idea how I can extract the STRING_OF_INTEREST portion? The need is for mod rewrite rules in apache... so, it could start with https/http/www/WWW/etc...
thanks in advance,
skenderbeg |
|
 |
|
return new Regex(strRegex).IsMatch(Url); |
|
 |
| | Thank you. Your email check was the only one I could use in pl/sql |
|
 |
| | I'm trying to extract the basic regex to use in a different platform. Why are some of the "@" characters *outside* the quotes in the string-concetenation? Is this a special use of "@" - I don't do C# |
|
 |
| |
 |
| Thank for the regex,
Regards,
Mike
http://www.growshop.com |
|
 |
| | thank you so much!!!!!!!!!!! |
|
 |
| for matching ALL URIs with port numbers, the part "(:[0-9]{1,4})?" has to be changed into "(:([0-5][0-9]{1,4})|(6[0-4][0-9]{3})|(65[0-4][0-9]{2})|(655[0-2][0-9])|(6553[0-5]))?"
then it will also match the port numbers from 10000 to 65535...
that regex also matches http://999.999.999.999 as an IP-adress...
and adresses with subdomains (srv.subdomain.SLD.TLD) aren't matched...
i think that regex might work on some URLs, but it's still very uncomplete |
|
 |
| Cheers
http://www.eternumonline.com |
|
 |
| Nice, thank you.
(http://www.cyclopsvue.blogspot.com) |
|
 |
| | Thanks a lot for such a nice snippet of coding. It really helped me a lot. online games |
|
 |
| |
 |
| I tried a lot of regex for url validation and this is the best one i've seen.
Thanks. |
|
 |
| Thank you for this excellent working and good documented regex!!
i used it for my website
Kochrezepte |
|
 |
| What would a valu vb .net regex expression be for the following pattern:
<core:url address="somewebaddress">
e.g.
<core:url address="www.communities.gov.uk/documents/localgovernment/pdf/155181.pdf"> |
|
 |
| ^(http\:\/\/|[a-zA-Z0-9_\-]+(?:\.[a-zA-Z0-9_\-]+)*\.[a-zA-Z]{2,4}(?:\/[a-zA-Z0-9_]+)*(?:\/[a-zA-Z0-9_]+\.[a-zA-Z]{2,4}(?:\?[a-zA-Z0-9_]+\=[a-zA-Z0-9_]+)?)?(?:\&[a-zA-Z0-9_]+\=[a-zA-Z0-9_]+)*)$
everyone
plz follw this regular expression for url
http://www.communities.com/regexp/
or
www.communities.com
thanks from
shital jamdade
|
|
 |
| | Thanks. Really helpfull site. |
|
 |
| | <a href="http://www.qualitycodes.com/tutorial.php?articleid=28">http://www.qualitycodes.com/tutorial.php?articleid=28</a> lists all the common regular expressions |
|
 |
| |
 |
| if(p) return true; else return false;
is better written:
return p; |
|
 |
| |
 |
| perhaps you could use the Uri object to check valid url:
Uri.IsWellFormedUriString("http://www.someuri.com", UriKind.RelativeOrAbsolute);
|
|
 |
| | Thanks.Good site.[url=http://mobile-games.bwap.org/free mobile games[/url] |
|
 |
| |
 |
 |
 |
 |
Anonymously add a comment: (or register