|
-
Jul 16th, 2008, 10:22 AM
#1
Thread Starter
Fanatic Member
How to check that a string is a proper URL
That starts with http://
Using regular expression
Can I see a code
Thanks
-
Jul 16th, 2008, 11:46 AM
#2
Re: How to check that a string is a proper URL
The easy way is to attempt to navigate to that place - if success then url is valid.
You may parse it but there could still be margin for error...
-
Jul 16th, 2008, 01:24 PM
#3
Re: How to check that a string is a proper URL
How about something simple like
Code:
If Left(Text1.Text, 7) <> "http://" Then
MsgBox "Invalid URL"
End If
-
Jul 16th, 2008, 05:23 PM
#4
Re: How to check that a string is a proper URL
Why user regex when its simple to use string functions like hack posted?
What are the reqquirements for the urls? "https://", "ftp://", "ftps://" etc?
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Jul 16th, 2008, 06:42 PM
#5
Re: How to check that a string is a proper URL
So, what happens if all you have is this:
"http://www"
It does have "http" in it but it still ain't valid... As I said best way to validate url is to try to navigate there.
-
Jul 16th, 2008, 10:38 PM
#6
Thread Starter
Fanatic Member
Re: How to check that a string is a proper URL
Well because I have 10000 URL to check and I want to do it quickly. Surfing them one by one is not a good idea.
Doesn't have to be regex but regex seems to be the way to go.
Let's see we can make sure it has only one http:// or https://
Then we look at the content between http:// and the next /
Then we look that those between and after that consists of numbers and letters allowed in a URL
There has to be regex for this one already.
-
Jul 16th, 2008, 11:25 PM
#7
Re: How to check that a string is a proper URL
Check left side as already mentioned. Check if there are unescaped characters, e.g. spaces instead of %20. URL may then be syntactically valid... but real validity can only be tested by navigation.
-
Jul 16th, 2008, 11:58 PM
#8
Re: How to check that a string is a proper URL
Well what is it that you want to accomplish? Check for valid syntax only or check for valid syntax and know the url points to a valid site?
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Jul 17th, 2008, 01:52 AM
#9
Thread Starter
Fanatic Member
Re: How to check that a string is a proper URL
Only valid syntax.
Of course the only way to know that the URL is valid is by actually visiting the URL.
No. Just valid syntax.
-
Jul 17th, 2008, 02:34 AM
#10
Re: How to check that a string is a proper URL
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|