-1
I’m using Javascript to manipulate some strings that comes from an API and I need to remove the zip code and country from one of these strings.
Basically, I get the phrase like this:
"R. Anderson Ferreira dos Réis, 122 - Conj. Hab. Joel Marques, Tauá - CE, 63660-000, Brasil"
And I need to make arrangements to get rid of the zip code and the country, like this:
"R. Anderson Ferreira dos Réis, 122 - Conj. Hab. Joel Marques, Tauá - CE"
I know it is possible to use the replace() method for this, but the regex I used didn’t work. I tried something like this to get Cpf off:
let text = "R. Anderson Ferreira dos Réis, 122 - Conj. Hab. Joel Marques, Tauá - CE, 63660-000, Brasil"
const result = text.replace(/\d\d((\d\d\d)|(\.\d\d\d-))\d\d\d, '')
But that code doesn’t work.
Someone would know how to do it the right way?
I believe in the title of your question is ZIP code instead of CPF, right?
– Marcelo Vismari