English 中文(简体)
Notepad++中替代物的登记
原标题:Regex in Notepad++ for replacement

i ve search for that info, but can t to figure out how to understand properly a regular expression. I have a html file and there are multiple <img> tags. Each of these tags have attribe src with following data: /newsletter/images/light/b/NUMERICVALUE/IMAGENAME.jpg

Assuming that the NUMERICVALUE and the IMAGENAME are always different value in each src attribute.

所需要的是从每公升中删除<代码>/NUMERICVALUE。 怎样才能做到这一点?

感谢任何建议。

这方面的例子有:

/newsletter/images/light/b/617359405/lf-header.jpg /newsletter/images/light/b/617359406/up-logo.jpg /newsletter/images/light/b/617359407/logo-header.jpg

最佳回答

Search: src="/newsletter/images/light/b/[^/]*/([^"]*)"
Replace: src="/newsletter/images/light/b/1"

解释:

  • Defines the full URI: /newsletter/images/light/b/[^/]*/([^"]*)
  • This will find anything WITHOUT a / slash [^/]*
  • This will find anything WITHOUT a " quote ([^"]*)
  • The ( and ) tells the regular expression engine to capture the content of it
  • In the replacement 1 forces the regular expression engine to insert capture 1 at this place

<>Edit: 最新数据可在所有<代码>src=属性上使用,如评论意见所述。

问题回答

我猜测“NUMERICVALUE”是一种实际数字价值,因此是一种简单的解决办法:

Find what: /newsletter/images/light/b/d+/([a-zA-Z0-9_]+).jpg
Replace with: /newsletter/images/light/b/1.jpg

页: 1

这几乎与方案拟订有关,但无论如何:

Find what: (<img src=.*/)d+/
Replace with: 1

投入:

<img src="/newsletter/images/light/b/654/IMAGENAME.jpg"/>
<img src="/newsletter/images/light/b/5752/IMAGENAME.jpg"/>
<img src="/newsletter/images/light/b/78697345/IMAGENAME.jpg"/>
<img src="/newsletter/images/light/b/7896789/IMAGENAME.jpg"/>
<img src="/newsletter/images/light/b/45/IMAGENAME.jpg"/>
<img src="/newsletter/images/light/b/8/IMAGENAME.jpg"/>
<img src="/newsletter/images/light/b/4567837/IMAGENAME.jpg"/>

产出:

<img src="/newsletter/images/light/b/IMAGENAME.jpg"/>
<img src="/newsletter/images/light/b/IMAGENAME.jpg"/>
<img src="/newsletter/images/light/b/IMAGENAME.jpg"/>
<img src="/newsletter/images/light/b/IMAGENAME.jpg"/>
<img src="/newsletter/images/light/b/IMAGENAME.jpg"/>
<img src="/newsletter/images/light/b/IMAGENAME.jpg"/>
<img src="/newsletter/images/light/b/IMAGENAME.jpg"/>




相关问题
CSS working only in Firefox

I am trying to create a search text-field like on the Apple website. The HTML looks like this: <div class="frm-search"> <div> <input class="btn" type="image" src="http://www....

image changed but appears the same in browser

I m writing a php script to crop an image. The script overwrites the old image with the new one, but when I reload the page (which is supposed to pickup the new image) I still see the old one. ...

Firefox background image horizontal centering oddity

I am building some basic HTML code for a CMS. One of the page-related options in the CMS is "background image" and "stretch page width / height to background image width / height." so that with large ...

Separator line in ASP.NET

I d like to add a simple separator line in an aspx web form. Does anyone know how? It sounds easy enough, but still I can t manage to find how to do it.. 10x!

热门标签