Multi Url Picker and regular expression for validation
Using Umbraco 8.6.2
I'm using a Multi Url Picker (with minimum and maximum number of links set to 1), and when editting content you have two options.
Either type in the (extarnal) url in het field Link in this form "https://....."
And you can enable the Validation and set it to validate as Url.
Which by default uses the following regular experssion: https?://[a-zA-Z0-9-.]+.[a-zA-Z]{2,}|
Which although it isn't perfect does the job of validating external url's pretty well.
But the problem is you also have to option to use Link To Page, which enables you to select an internal page. But the issue is the Link url then becomes:
/..pageurl../ which fails the default expression.
So I've created a custom one, checked it with all regular expression validators I could find online:
Multi Url Picker and regular expression for validation
Using Umbraco 8.6.2
I'm using a Multi Url Picker (with minimum and maximum number of links set to 1), and when editting content you have two options. Either type in the (extarnal) url in het field Link in this form "https://....." And you can enable the Validation and set it to validate as Url. Which by default uses the following regular experssion: https?://[a-zA-Z0-9-.]+.[a-zA-Z]{2,}|
Which although it isn't perfect does the job of validating external url's pretty well.
But the problem is you also have to option to use Link To Page, which enables you to select an internal page. But the issue is the Link url then becomes:
/..pageurl../ which fails the default expression.
So I've created a custom one, checked it with all regular expression validators I could find online:
So basicly check if it's https://..validurl.. or /..pagename..
https?://[a-zA-Z0-9-.]+.[a-zA-Z]{2,}|^[/].[a-zA-Z0-9-/.?&]+
And
(https?://[a-zA-Z0-9-.]+.[a-zA-Z]{2,}|^[/])
And
https?://[a-zA-Z0-9-.]+.[a-zA-Z]{2,}|^[/]
All 3 work in https://regexr.com/ and https://www.regextester.com/ but fail in Umbraco.
So anybody any idea to make this work (besides disabling validation entirely) ?
try this expresstion
[(http(s)?):\/\/(www.)?a-zA-Z0-9@:%.+~#=]{2,256}.[a-z]{2,6}\b([-a-zA-Z0-9@:%+.~#?&//=]*)
is working on a reply...