I have this regex in a query in postgres and I cannot figure out why it is not matching anything after the text specified in the regex;
The idea is removing the last part, including the separator characters between.
I have records like these to match:
Villa hermosa, Pilar, PCIA. BS. AS.
Esmeralda - Pilar - BUENOS AIRES.
San Martin, BUENOS AIRES.-
and I'm 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 is working fine from the text PCIA, BUENOS, but it is not taking the ',' '.' the '-' nor spaces after the word. I need help finding where the problem is.