简体   繁体   English

如何在记事本中删除两个字符或字符串之间的空格

[英]How to remove a space between two characters or strings in notepad++

Consider I have a string in quotations "( the" which occures in a huge body of text. 考虑一下,我有一个用引号引起来的字符串"( the" ,它出现在大量文本中。

I want to remove the space between non-alphanumeric ( and aplphanumeric t characters 我想删除非字母数字(和字母数字t字符之间的空格

Replace match of regular expression pattern (?<=\\()\\s+(?=t) with empty string. 用空字符串替换正则表达式模式(?<=\\()\\s+(?=t)匹配项。

正则表达式可视化

If any alphanumeric character may occur after such space, then use pattern (?<=\\()\\s+(?=[^\\W_]) 如果在此空格之后可能出现任何字母数字字符,则使用模式(?<=\\()\\s+(?=[^\\W_])

正则表达式可视化

Per this answer if you are using version 6.0 or later you can use Perl compatible regular expressions. 根据此答案,如果您使用的是6.0版或更高版本,则可以使用与Perl兼容的正则表达式。 So you could do the following regex search and replace. 因此,您可以执行以下正则表达式搜索并替换。

replace (\W) (\w) with \1\2
replace (\w) (\W) with \1\2

This will remove the space between any non-alphanumeric and alphnumeric characters first, then the reverse (alnum, space, non-alnum). 这将首先删除所有非字母数字字符和字母数字字符之间的空格,然后反向(数字,空格,非数字)。

Following regex find/replace will do it for all, not only ( t occurrences: 遵循正则表达式查找/替换将不仅对所有事件( t次出现:

Find: \\( ([a-zA-Z]) 查找: \\( ([a-zA-Z])

Replace: \\(\\1 替换为: \\(\\1

Remember to check Regular expression on the bottom of the dialog. 切记检查对话框底部的正则表达式

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

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