Re: [pcre-dev] PCRE regex for hex number

Top Page
Delete this message
Author: Philip Hazel
Date:  
To: Peng Yu
CC: pcre-dev
Subject: Re: [pcre-dev] PCRE regex for hex number
Try

^[-+]?0[Xx][[:xdigit:]]++(?![.G-Zg-z])

Note the additional '+'. This ensures that once it has matched the xdigits,
it does not release any of them.

Regards,
Philip


On Mon, 24 May 2021 at 04:33, Peng Yu via Pcre-dev <pcre-dev@???>
wrote:

> I use the following regex.
>
> ^[-+]?0[Xx][[:xdigit:]]+(?![.G-Zg-z])
>
> and the following string
>
> 0x10g
>
> on using PCRE.
>
> https://regex101.com/
>
> It matches 0x1. I want it to be no match. Is there a way to modify the
> regex so that only matches valid hex numbers? Thanks.
>
> --
> Regards,
> Peng
>
> --
> ## List details at https://lists.exim.org/mailman/listinfo/pcre-dev
>