Re: How best to work around the issue - regex string cannot contain brackets
От | Steve Midgley |
---|---|
Тема | Re: How best to work around the issue - regex string cannot contain brackets |
Дата | |
Msg-id | CAJexoSLhiG210dVajgbkY9z1cH6xZ+vxEKthaZ+HnsTwCbUhqA@mail.gmail.com обсуждение исходный текст |
Ответ на | Re: How best to work around the issue - regex string cannot contain brackets ("David G. Johnston" <david.g.johnston@gmail.com>) |
Список | pgsql-sql |
On Fri, Feb 4, 2022 at 9:24 AM David G. Johnston <david.g.johnston@gmail.com> wrote:
On Fri, Feb 4, 2022 at 10:14 AM Steve Midgley <science@misuse.org> wrote:On Fri, Feb 4, 2022 at 6:01 AM Shaozhong SHI <shishaozhong@gmail.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}Show your work!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.
Apologies - I was relying on stackoverflow and my prior experiences with regex engines that don't honor shorthand characters inside brackets. I should have tested postgres latest before responding. Thanks for the correction. (https://stackoverflow.com/questions/46020936/perl-like-shorthand-character-class-not-working-inside-bracket-expression)
В списке pgsql-sql по дате отправления: