I have the following regex in JavaScript regex
(https?|ftp)://([-A-Z0-9.]+)(/[-A-Z0-9+&@#/%=~_|!:,.;]*)?(\\?[A-Z0
Your pattern doesn't look for lowercase characters. Either you add a-z
to the respective character groups or you use caseSenstivie: false
as shown in the code.
var urlPattern = r"(https?|ftp)://([-A-Z0-9.]+)(/[-A-Z0-9+&@#/%=~_|!:,.;]*)?(\?[A-Z0-9+&@#/%=~_|!:,.;]*)?";
var result = new RegExp(urlPattern, caseSensitive: false).firstMatch('https://www.google.com');
If the result is != null a match was found.
Your pattern doesn't find http:
URLs (only https
or ftp
) neither www.google.com
.
Your statement about 'empty space' might apply to your email regexp you had in your question originally but not to your URL regexp you added in your comment.