简体   繁体   English

Notepad ++的正则表达式可以代替它吗?

[英]Regular expression for Notepad++ to replace this?

This is an example of what I want to replace 这是我要替换的示例

3</td><td width="8%">2

with

3 and 2

But the regex should match any number before the like the 3 above for the example, and the number 2 is always number 2 但是正则表达式应该与前面的示例中的3之前的任何数字匹配,并且数字2始终是数字2

if you find a number before </td><td width="8%"> and the number 2 after it, you keep the numbers and replace </td><td width="8%"> with the word and 如果您在</td><td width="8%">之前找到一个数字,并在其后找到数字2,则保留数字并将</td><td width="8%">替换为单词and

Thank you 谢谢

You can try to match with the following regex: 您可以尝试与以下正则表达式匹配:

([0-9]+)</td><td\s*width="8%">2

and replace with the following: 并替换为以下内容:

$1 and 2

Look at the picture below: 看下面的图片:

正则表达式

I believe this should work: 我相信这应该有效:

[0-9]+</td><td\\swidth="8%">2

If you editor supports groupped editing, use paranthesis to mark each group then edit the one you need. 如果您的编辑器支持分组编辑,请使用括号标记每个组,然后编辑所需的组。

Groupped version: 分组版本:

([0-9]+)(</td><td\\swidth="8%">)(2)

Capture the preceding number and output it back out in the replacement text using a back reference: 捕获前面的数字,并使用反向引用将其输出回替换文本中:

Search: 搜索:

(\d+)</td><td width="8%">2

Replace: 更换:

\1 and 2

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

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