| From: | Steve Midgley <science(at)misuse(dot)org> |
|---|---|
| To: | Shaozhong SHI <shishaozhong(at)gmail(dot)com> |
| Cc: | "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>, Christophe Pettus <xof(at)thebuild(dot)com>, pgsql-sql <pgsql-sql(at)lists(dot)postgresql(dot)org> |
| Subject: | Re: How best to work around the issue - regex string cannot contain brackets |
| Date: | 2022-02-04 17:14:39 |
| Message-ID: | CAJexoS+QpHS3tdn9ff7kfVYqXmEFhw3=8zV-ZM8K8UW0JLkg8Q@mail.gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-sql |
On Fri, Feb 4, 2022 at 6:01 AM Shaozhong SHI <shishaozhong(at)gmail(dot)com> wrote:
> It appears that the following regex work differently.
>
> Why \d and [\d] are different?
>
> [A-PR-UWYZ]\d{1,2} and [A-PR-UWYZ][\d]{1,2}
>
>>
>>
This is getting into regex stuff, where maybe stackoverflow is a better
resource? But when you put characters into brackets, you are telling regex
to search for each character represented in the bracket. So [\d] is looking
for any single character that is either a \ or a d character. Outside of
brackets, regex evaluates \d as any digit. For US English charset [0-9] is
equivalent to \d I believe.
| From | Date | Subject | |
|---|---|---|---|
| Next Message | David G. Johnston | 2022-02-04 17:24:24 | Re: How best to work around the issue - regex string cannot contain brackets |
| Previous Message | Shaozhong SHI | 2022-02-04 14:00:55 | Re: How best to work around the issue - regex string cannot contain brackets |