I am trying to create a regular expression to match a website URL for some form validation. Here is the regex I am using:
^((http|ftp|https):\/\/)?([\w_-]+(?:(?:\.[\w_-]+)+))([\w.,@?^=%&:\/~+#-]*[\w@?^=%&\/~+#-])?$
While I know that this is not a “perfect” regex for validating a URL, I am getting inconsistencies between using the regex in ionic vs. my web tests.
For example, i plugged the regex into http://www.regex101.com and several examples are working just fine:
http://www.google.com
google.com
www.google.com
However, when I run my ionic app, none of my patterns are matching.
I know that I am using Validators.pattern()
properly because I have already added a regex validator for email inputs. I also know that I’m using it properly because I am able to plug in simple patterns, like http
ang the validation works fine.
Somewhere along the way, the Ionic pattern is failing to parse as a normal regex would.
Is there something about using regex in Ionic that I am missing?