Can we make regexp processing more friendly by recognizing "\r\n" as a "newline" for "^$" purposes? - Mailing list pgsql-general

From David G. Johnston
Subject Can we make regexp processing more friendly by recognizing "\r\n" as a "newline" for "^$" purposes?
Date
Msg-id CAKFQuwYb92TXJ+EcL9dr7MACbHWRR8Ri976oGm_wtW6D7nh92w@mail.gmail.com
Whole thread Raw
Responses Re: Can we make regexp processing more friendly by recognizing "\r\n" as a "newline" for "^$" purposes?
List pgsql-general
Other implementation of regular expressions handle "newline" mechanics related to "^" and "$" semantically instead of literally.  By that I mean that both "\r\n" and "\n" are considered "newlines" instead of just "\n".

If changing behavior is not desirable I would be content with another flag that would toggle such behavior.

In code - both of these subqueries should match whereas presently only the first one does.

SELECT regexp_matches(E'123\n',   E'123$', 'w');
SELECT regexp_matches(E'123\r\n', E'123$', 'w');

I don't know if this is server O/S dependent...but I would not expect it to be so.

Having to say something like:  , 'wr'  (r = combine-\r-with-adjacent-newline) would be OK but not ideal.  I'm not seeing much risk in changing this particular behavior.

Thanks!

David J.

P.S. Forgive me for re-iterating the dislike of calling and describing "w" as "weird" and "rarely useful".  I find it to be quite useful and my source material doesn't seem particularly unusual.

pgsql-general by date:

Previous
From: Thomas Kellerer
Date:
Subject: Re: PSQL Tools
Next
From: jwiencek3@comcast.net
Date:
Subject: Re: PSQL Tools