Search code examples
regexhexpowerapps

Is there a way to check the maximum hex value allowed in a string?


I have to check a string which should only contain hex values (using regex code ^[a-fA-F0-9]{1,14}$ here) for a maximum allowed value.

The allowed hex range for the string is between 0 and 1fffffffffffff.

Is there any way to check this with regex?


Solution

  • Is that what you want:

    ^(?:[01][a-f0-9]{13}|[a-f0-9]{1,13})$
    

    Code:

    IsMatch(string, "^(?:[01][a-f0-9]{13}|[a-f0-9]{1,13})$", IgnoreCase)