RegEx:如果后面的内容显示为小写,请删除换行符 [英] RegEx : Remove line breaks if lookbehind shows a lowercase

查看:84
本文介绍了RegEx:如果后面的内容显示为小写,请删除换行符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在记事本++中进行CTRL + H(查找和替换)

I'm doing a CTRL+H (Find & Replace) in Notepad++

我想找到所有换行符,后跟小写字符,以便用空格字符替换它们;从而删除了我文本中不必要的换行符.

I want to find all Line breaks followed by lowercase characters in order to replace them with a space character ; thereby removing unwanted break lines in my text.

查找: \ r \ n +(?![A-Z] | [0-9])

替换:在此处插入空格字符

*请确保您选择了"区分大小写"和"正则表达式".

*Make sure you selected "Match case" and "Regular expression".

效果很好.

现在,我想在Microsoft Office Word文档中做同样的事情.有任何线索吗?

Now, I'd like to do the same in Microsoft Office Word documents. Any clues?

推荐答案

在Microsoft Word中,执行以下操作:

In Microsoft Word, do the following:

  1. 在主页"选项卡上的编辑"组中,单击替换"以打开查找和替换"对话框.

  1. On the Home tab, in the Editing group, click Replace to open the Find and Replace dialog box.

选中Use wildcards复选框.如果没有看到使用通配符"复选框,请单击更多",然后选择该复选框.

Check the Use wildcards check box. If you don't see the Use wildcards check box, click More, and then select the check box.

Find what:框中,输入以下正则表达式:([a-z])^13

In the Find what: box, enter the following regular expression: ([a-z])^13

Replace with:框中,输入:\1-那就是:(反斜杠1空格)(不要忘记空格!)

In the Replace with: box, enter: \1 - thats: (backslash 1 SPACE) (don't forget the space!)

就是这样!然后单击Replace按钮或Replace All按钮.

And that's it! Then click either the Replace button or the Replace All button.

注意:在MS Word中,^13字符与每行末尾的段落标记匹配.

Note: In MS Word, the ^13 character matches the paragraph mark at the end of each line.

有关Microsoft Word和正则表达式的更多信息-

Here's more information about Microsoft Word and Regular Expressions - http://office.microsoft.com/en-us/word-help/find-and-replace-text-by-using-regular-expressions-advanced-HA102350661.aspx

哦,上面的命令与小写字母PRECEDING换行符匹配.

Oh, the above matches lowercase letter PRECEDING line break.

如果要匹配以小写字母跟随的换行符,请执行以下操作:

If you want to match line break FOLLOWED by lowercase letter, do the following:

  1. Find what:框中,输入以下正则表达式:^13([a-z])

  1. In the Find what: box, enter the following regular expression: ^13([a-z])

Replace with:框中,输入:\1-多数民众赞成:(空格反斜杠1)(不要忘记空格!)

In the Replace with: box, enter: \1 - thats: (SPACE backslash 1) (don't forget the space!)

对这两种方式都进行了测试,它们都可以在Microsoft Word 2010中使用,但是文档指出,所有版本97-2013中都支持正则表达式.

Tested both ways and they both work in Microsoft Word 2010, however documentation says that regular expressions are supported in all versions 97 - 2013.

祝你好运! :)

这篇关于RegEx:如果后面的内容显示为小写,请删除换行符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆