简体   繁体   English

记事本++中的合并行

[英]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. 我可以使用(?-s)^(Address:).*\\R.*来选择文本,但似乎无法找出替换表达式。

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

Replace with: \\1 \\2\\t\\3\\t\\4 替换为: \\1 \\2\\t\\3\\t\\4

Search for \\R(?=A) and replace with 搜索\\R(?=A)并替换为 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: 这已经按照注释中的要求拆分了City,ST和Zip:

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. 我接下来要进行的操作是解析城市ST 12345,这样它将是City \\ t ST \\ t 12345,以便在保存为CSV时可以按城市,ST和Zip进行排序。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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