Skip to content

Instantly share code, notes, and snippets.

@W3BGUY
Last active February 20, 2023 12:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save W3BGUY/760f2412a9387099ee71386079eb2f6f to your computer and use it in GitHub Desktop.
Save W3BGUY/760f2412a9387099ee71386079eb2f6f to your computer and use it in GitHub Desktop.
Validate a URL format using RegExMatch()
<trans>
url='www.test.net';
url='http://www.test.com lkjasdhfkhasdf';
if(Left(ToLower(url),4)!='http' && Left(ToLower(url),5)!='https',
url='https://'+url;
);
regTest='^((http|https):\/\/)?(www.)?(?!.*(http|https|www.))[a-zA-Z0-9_-]+(\.[a-zA-Z]+)+((\/)[\w#]+)*(\/\w+\?[a-zA-Z0-9_]+=\w+(&[a-zA-Z0-9_]+=\w+)*)?\/?$';
if(RegExMatch(url,regTest)!=-1,
url;,
Unmap();
);
</trans>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment