Url Regex Passed By Regex Buddy But Failed By Dart
I have the following regex in JavaScript regex (https?|ftp)://([-A-Z0-9.]+)(/[-A-Z0-9+&@#/%=~_|!:,.;]*)?(\?[A-Z0-9+&@#/%=~_|!:,.;]*)? It attempts to validate and emp
Solution 1:
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.
Post a Comment for "Url Regex Passed By Regex Buddy But Failed By Dart"