简体   繁体   English

在Notepad ++中使用正则表达式查找和替换

[英]Find and replace using regular expressions in Notepad++

I have to make changes to URL's in a couple of notepad files. 我必须在几个记事本文件中更改URL。 I was hoping if this could be done using regular expressions. 我希望是否可以使用正则表达式来完成。

The URL's are in the following structure, URL的结构如下,

/web/20120730114452im_/hxxp://mysite1.com
/web/20120730114453im_/hxxp://mysite2.com
/web/20120730114454im_/hxxp://mysite3.com
/web/20120730114454im_/hxxp://mysite4.com

I have to remove the part before the hxxp so what remains after the search and replace is, 我必须在hxxp之前删除该部分,以便在搜索和替换之后剩下的是,

hxxp://mysite1.com
hxxp://mysite2.com
hxxp://mysite3.com
hxxp://mysite4.com

What is the regular expression I need to use to get the desired result ? 我需要使用什么正则表达式来获得所需的结果?

Thanks for your help. 谢谢你的帮助。

USE THIS, 用这个,

FIND:      [ a-z 0-9 _ / ]+/hxxp
REPLACE:   hxxp

Okay, as per your confirmation, a proper regex that won't match too much would be this: 好的,根据您的确认,正确的正则表达式不会太匹配将是这样的:

/web/[0-9]+im_/

Where [0-9]+ will match any amount of numbers. 其中[0-9]+将匹配任意数量的数字。

regex101 demo . regex101演示

Don't forget to check the 'regular expression' checkbox in the Find/Replace dialog box. 不要忘记在“查找/替换”对话框中选中“正则表达式”复选框。

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

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