= 126.96.36.199/8 are excluded by the second validation block. It is easy to just remove the unwanted parts of the validation to fit different scopes (length, precision) so I will probably add more options like the list of existing TLD (possibly grouped), the list of existing protocols and/or a fall back for a more generic protocol match too. This a very minimal list of tests to add to your testings: PASS " " " FAIL " " " " " Need testing :) Need to mention I took the idea of validating the possible IP address ranges in the URL while looking at other developers regular expressions I have seen in your tests, especially the one from @scottgonzales. This a very minimal list of tests to add to your testings: PASS " " " FAIL " " " " " Need testing :) I have added simple network ranges validation, the rules I used are: - valid range 188.8.131.52 - 184.108.40.206, network adresses above and including 220.127.116.11 are reserved addresses - first and last IP address of each class is excluded since they are used as network broadcast addresses since I don't think this is worth implementing completely in a regular expression, a following pass should exclude the Intranet address space: 10.0.0.0 - 10.255.255.255 172.16.0.0 - 1.255 192.168.0.0 - 192.168.255.255 the loopback and the automatic configuration address space: 127.0.0.0 - 127.255.255.255 169.254.0.0 - 169.254.255.255 while the local, multicast and and the reserved address spaces: 0.0.0.0 - 0.255.255.255 (SPECIAL-IPV4-LOCAL-ID-IANA-RESERVED) 18.104.22.168 - 239.255.255 (MCAST-NET) 240.0.0.0 - 255.255.255.255 (SPECIAL-IPV4-FUTURE-USE-IANA-RESERVED) should already be excluded by the above regular expression. my Java Script URI parsing library does strict URI validation as per RFC 3986. Code can be found at: https://github.com/garycourt/uri-js Hey, just randomly came across this... In Java Script, regular expressions are often used with the two string methods: search() and replace().The search() method uses an expression to search for a match, and returns the position of the match.
He also sliced up the Unicode ranges :=), that's the reason his one is so long :) Need to mention I took the idea of validating the possible IP address ranges in the URL while looking at other developers regular expressions I have seen in your tests, especially the one from @scottgonzales. The following expression is pretty lenient on the format and should accept 999-999-9999, 9999999999, (999) 999-9999.Make sure to be in global mode (g flag), case insensitive and to have the dot all option on.If you need more examples or solutions, please contact me. Note that in character sets, special characters (., *, ) do not have any special meaning. This means match anything that is a single white space character OR anything that is not a white space character!DOTALL is a flag in most recent regex libraries that makes the . There is no 100% reliable solution since the RFC is way too complex. ] )*@([a-z0-9_][-a-z0-9_]*(\.[-a-z0-9_] )*\.(aero|arpa|biz|com|coop|edu|gov|info|int|mil|museum|name|net|org|pro|travel|mobi|[a-z][a-z])|([0-9]\.[0-9]\.[0-9]\.[0-9]))(:[0-9])? $ This will make sure that every number in the IP address is between 0 and 255, unlike the version using \d which would allow for 999.999.999.999.This regular expression will match all HTML tags and their attributes.