It seems I’m not the only one with Vista issues
Have we really waited 5 years for this?
It seems I’m not the only one with Vista issues
Have we really waited 5 years for this?
I think I’m going to have add a post category for ‘vista annoyances’!
Why when I extract a zip file with the in-built windows compression utility, does it take a ridiculously long time to complete! I’m fed up with this now, I’m installing 7Zip.
I don’t do a great deal of classic ASP any more, but today I had to knock up a quick function to try and filter out those annoying form spammers. You know the ones, feedback forms submitted with just URLs pointing to pr0n and viagra sites!
Anyway, I came up with a function that counts URLs in a block of text –
Function UrlCount(text) dim strRegex strRegex = "(https?://)?(([0-9a-z_!~*'().&=+$%-]+: )? [0-9a-z_!~*'().& =+$%-]+@)?(([0-9]{1,3}.){3}[0-9]{1,3}| ([0-9a-z_!~*'()-]+.)*([0-9a-z] [0-9a-z-]{0,61})?[0-9a-z].[a-z] {2,6}) (:[0-9]{1,4})?((/?)|(/[0-9a-z_!~*'().;?:@&=+$,%#-]+)+/?)" 'Prepare a regular expression object Set myRegExp = New RegExp myRegExp.IgnoreCase = True myRegExp.Global = True myRegExp.Pattern = strRegex Set myMatches = myRegExp.Execute(text) UrlCount = myMatches.count Set myMatches = nothing Set myRegExp = nothing End Function
Thanks to this url regex I had it sorted in no time 🙂
Usage –
If UrlCount(variablecontainingfieldvaluetocheck) > 1 then ' you could use 2+ above if you don't want to be so strict ' do something nasty like drop a 404 End If
Anyway, let me know if you find it useful or have any suggestions for improvement.