Click here to Skip to main content
15,890,282 members
Please Sign up or sign in to vote.
1.00/5 (3 votes)
See more:
I'm getting an eror on the first part, incorrect declaration and line not ending properly

Also an error on the second part not ending properly.

MSIL
Unsigned Char Regex RgUrl;
Regex RgxUrl = new Regex("(([a-zA-Z][0-9a-zA-Z+\\-\\.]*:)?/{0,2}[0-9a-zA-Z;/?:@&=+$\\.\\-_!~*'()%]+)?(#[0-9a-zA-Z;/?:@&=+$\\.\\-_!~*'()%]+)?");
if (RgxUrl.IsMatch(txtUrl.Text))
{
   MessageBox.Show("URL is valid.");
}
else
{
   MessageBox.Show("URL is invalid!");
}
Posted
Updated 10-Apr-11 6:20am
v2
Comments
Wendelius 10-Apr-11 11:48am    
Posting the code would help a lot.
Sandeep Mewara 10-Apr-11 11:54am    
No idea on what you are talking of! Just in case you don't know, we are not magicians and mind readers.
CPallini 10-Apr-11 13:52pm    
That isn't C code. Please change the question tag.

1 solution

This Regular Expression matched almost everything (if limits the matches at all). Hard to say what was your idea, but URL validation usually looks simpler.

This is a collection of Regular Expressions on the URL validations topics: http://regexlib.com/Search.aspx?k=URL[^].

Do any of them do what you need?

—SA
 
Share this answer
 
v2
Comments
Espen Harlinn 10-Apr-11 15:17pm    
Good link - on the very top of the google result for: regex validate url
My 5 :)
Sergey Alexandrovich Kryukov 10-Apr-11 15:39pm    
Thank you, Espen. Hope this is enough to find the solution.
--SA
Member 7766180 10-Apr-11 17:37pm    
Thanks im just trying to get the url from thhe current packet
Sergey Alexandrovich Kryukov 10-Apr-11 20:56pm    
This is a different problem; it does not require validation.
How about URL validation using Regex, is your problem solved?
--SA
Wendelius 10-Apr-11 15:20pm    
Helpful link with lots of variations, 5'd

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900