Hey all,
We've been trying to get a validator up and running via RegEx expression within the Web Forms editor to validate a URL. For some background, I don't really care if they mess up the URL itself, it's more that I need it to be a hyperlink because we're using PowerAutomate to pass through this data and these text fields are being mapped to a hyperlink field. Validating the URL prevents flow failure.
/^(https?|ftp):\/\/[^\s]*$/i
Hopefully that formats correct but the RegEx I'm attempting to use breaks completely whenever it's contained for i, even if I use something like this one that allows for "NA" as well:
(?i)^(https?|ftp):\/\/[^\s]*$|^(NA)$
Any help is greatly appreciated. I have a feeling I have to write a validator in JavaScript instead of relying on the Pattern field in the web editor.
Dear @t.sheehy,
What kinds of URLs do you want it to match? Only https? Or do you want to include http or just www. or even links like google.com?
Let us know the requirements for link validation, we'll try to find the right RegEx for the use case.
We want links to start with http/https (was trying with the occasional ftp but that isn't necessary). I've noticed especially when using more restrictive RegEx it throws errors on SharePoint links.
The 2 main types would be links to a client's assets, or a link to our own SharePoint. So it needs to accept random symbols in the middle of the URL
Dear @t.sheehy,
Will this work?
^(https?:\/\/)([\w-]+(\.[\w-]+)+([\/?#][\w\-\.~:\/\?#\[\]@!\$&'\(\)\*\+,;=%.]+)?|[\w\-\.~:\/\?#\[\]@!\$&'\(\)\*\+,;=%.]+)$
1 Like
That works except if they enter the protocol in capitals or a mix, hence my struggle with making it case insensitive. I can always add a tip that the protocol has to be lower case.
Dear @t.sheehy,
You can try:
^([hH][tT][tT][pP][sS]?:\/\/)([\w-]+(\.[\w-]+)+([\/?#][\w\-\.~:\/\?#\[\]@!\$&'\(\)\*\+,;=%.]+)?|[\w\-\.~:\/\?#\[\]@!\$&'\(\)\*\+,;=%.]+)$
Thank you. is there any reason the i flag doesn't work in plumsail patterns?
This actually allows them to type full sentences in it seems and the form takes it.