简体   繁体   中英

Merger lines in Notepad++

I have a text file that contains the address on two lines, it will look like this:

Company Name
Address: 123 AnyStreet
AnyCity, ST 12345
Company Name
Address: 123 AnyStreet
AnyCity, ST 12345
Company Name
Address: 123 AnyStreet
AnyCity, ST 12345

I would like to get it to look like this:

Company Name Address: 123 AnyStreet AnyCity, ST 12345
Company Name Address: 123 AnyStreet AnyCity, ST 12345
Company Name Address: 123 AnyStreet AnyCity, ST 12345

I can get the text selected with (?-s)^(Address:).*\\R.* but can't seem to figure out the replace expression.

Find what: \\R(Address:.*)\\R([^,\\n]*), ST (.*)

Replace with: \\1 \\2\\t\\3\\t\\4

Search for \\R(?=A) and replace with space.

It uses a lookahead.

The Demo

Not a fancy solution, but it works just fine:

 Find What: ^(.*?)\\r\\n(.*?)\\r\\n(.*?),\\s+(.*?)\\s+(\\d+)$ Replace with: $1\\t$2\\t$3\\t$4\\t$5 

This already split City, ST and Zip as requested in comments:

My next bit of manipulation would be to parse the City, ST 12345 so that it would be City \\t ST \\t 12345 so I can sort by City, ST and Zip when saved as a CSV.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM