Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Patrick van Kemenade 97 posts 325 karma points
    Jun 05, 2020 @ 12:18
    Patrick van Kemenade
    0

    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) ?

  • fatmazayed 11 posts 81 karma points
    May 10, 2022 @ 15:18
    fatmazayed
    0

    try this expresstion

    [(http(s)?):\/\/(www.)[email protected]:%.+~#=]{2,256}.[a-z]{2,6}\b([[email protected]:%+.~#?&//=]*)

Please Sign in or register to post replies

Write your reply to:

Draft