Validate text as URL

I’m trying to check a text value to be a valid URL. However, I’m getting an unexpected result.

I’ve made a dummy page where I simply format the text colour to red/green based upon the condition result.

But the output is as follows (note there is no colour!):

Screenshot 2022-03-20 at 12.31.58

I know I haven’t checked for the the result being empty, but I would have expected the Regex to have correctly counted for at least one of these?

For completeness I added “is empty” as a third condition and the text remains black.

Have you validated the regex on a site like regex101.com? Be sure to choose the JS (ecmascript) flavor.

This topic was automatically closed after 70 days. New replies are no longer allowed.