Обсуждение: Possible RegEx bug for lower-case a and s characters

Поиск
Список
Период
Сортировка

Possible RegEx bug for lower-case a and s characters

От
"DeFreitas, Nigel"
Дата:

We observed that when we used this RegEx expression: [\s+|"]|[\n\r\f\a\t]|[^[:ascii:]]

The lowercase letters “a”, and “s” were also stripped from our data columns.

 

The RegEx expression seems to be error free as described here:

 

Text

Description automatically generated

 

 

Sample SQL to test:

 

select regexp_replace('Nigel DeFreit a  s', E'[\s+|"]|[\n\r\f\a\t]|[^[:ascii:]]','','g') AS result;

 

 




This email is intended solely for the recipient. It may contain privileged, proprietary or confidential information or material. If you are not the intended recipient, please delete this email and any attachments and notify the sender of the error.
Вложения

Re: Possible RegEx bug for lower-case a and s characters

От
"David G. Johnston"
Дата:


On Thu, Nov 17, 2022 at 4:00 AM DeFreitas, Nigel <nigel.defreitas@verisk.com> wrote:


select regexp_replace('Nigel DeFreit a  s', E'[\s+|"]|[\n\r\f\a\t]|[^[:ascii:]]','','g') AS result;



Don't use E strings when writing regex.  It adds a whole other layer of backslash escaping that you really don't want to deal with.

David J.