Regex in Postgres - not doing what I'm trying to do (newbie question)
I have this regex in a query in postgres and I can't figure out why it doesn't match anything after the text given in the regex;
The idea is to remove the last part, including the separator characters between them.
I have entries like these:
Villa hermosa, Pilar, PCIA. BS. AS.
Esmeralda - Pilar - BUENOS AIRES.
San Martin, BUENOS AIRES.-
and I am using this expression:
regexp_replace(location,
'([,\s\.-]*PCIA. BS. AS[,\s\.-]*|
[,\s\.-]*BUENOS. AIRES[,\s\.-]*$|
[,\s\.-]*BS. AS[,\s\.-]*$|
[,\s\.-]*P.B.A[,\s\.-]*$)', '' )
this works fine with PCIA, BUENOS text, but it doesn't take ",". "-" or spaces after a word. I need help finding the problem.
a source to share
Double backslash. \ => \\
Postgres thinks you are running screens of the line itself.
In newer versions of PostgreSQL, which is standard_conforming_strings
enabled by default, you no longer need to duplicate the backslash unless you use E'string'
or explicitly set standard_conforming_strings
- off
.
a source to share