Alex
Alex

Reputation: 17

Need a regex using Regular expression in Notepad++ for the replacing of one word per line

not long ago someone gave me the regex to replace a list of places for Missouri with the same pattern like this in which I wanted to replace (in Spanish) to |[[X (Misuri)|X]] || ciudad || 00 , where "city" was translated to "ciudad" in Spanish, where "X" is the name of the city, and "0" the population: From this

Acacia Villas city 427

to this:

|[[Acacia Villas (Misuri)|Acacia Villas]] || ciudad || 427

This was the regex that I used to replace those lines as shown above.

Search: (.)\scity\s(.)

Replace: |[[\1 (Misuri)|\1]] || ciudad

Now, I tried to modified the regex for the replacing for another list of places in Vermont (and other states), but i couldn't create the Regex,

The list goes like this: But this time i want to translate the county into Spanish and I want to eliminate 'town' just the one that are in lower cases and County in order to translate it to Spanish.

Andover town, Tolland County 3,303

Ansonia town, New Haven County 19,249

Ashford town, Windham County 4,317

Avon town, Hartford County 18,098 etc..

At the end each line should look like this, can anyone help me? :

|[[Andover (Vermont)|Andover]] || [[condado de Tolland (Vermont)|Tolland]] || 3,303

Another question, there is another list that i want to replace this time they are townships in Arkansas, and im not sure if the same regex for the towns will work for them, so im just gonna ask for the regex now just in case, eliminating the word township and County where Municipio is township in Spanish. Thank you!

For: Acorn township, Polk County 1,503

To: |[[Municipio de Acorn (condado de Polk, Arkansas)|Acorn]] || [[condado de Polk (Arkansas)|Polk]] || 1,503

Upvotes: 0

Views: 360

Answers (1)

bw_üezi
bw_üezi

Reputation: 4574

Search: (.*)\town,\s(.*)\Country\s(.*)
Replace: |[[\1 (Vermont)|\1]] || [[condado de \2 (Vermont)|\2]] || \3
Search: (.*)\township,\s(.*)\Country\s(.*)
Replace: |[[Municipio de \1 (condado de \2, Arkansas)|\1]] || [[condado de \2 (Arkansas)|\2]] || \3

Upvotes: 1

Related Questions