提取ID值,WITH "

Extract the ID value, WITH "

给定以下代码:

<div class="image-holder ui-draggable" title="something" id="image-138-1" 
style="height: 20px; width: 20px; background-image: url(&quot;http://example.com/userdata/138/image_5beb36c29fe79f5590054d05164c88f7.
gif&quot;); left: 0px; top: 0px; position: relative;"></div><div 
class="image-holder ui-draggable" title="something2" id="image-15230-4" 
style="height: 40px; width: 40px; background-image: url(&quot;http://example.com/userdata/135238/image_5beb36c29fwrdfsdfd05164c88f7.g
if&quot;); left: 0px; top: 0px; position: relative;"></div><div 
class="image-holder ui-draggable" title="somethinggfhgf" id="image-1388973-1" 
style="height: 30px; width: 10px; background-image: url(&quot;http://example.com/userdata/13456548/image_5beb3646456164c88f7.gif&quot
;); left: 0px; top: 50px; position: relative;"></div>

如何使用 Notepad++ 提取带有“ ”的 id-s 值。 示例:"image-138-1" "image-15230-4" "image-1388973-1"

正则表达式 (?<=id=)"image-\d+-\d+" 将查找文字文本 "image- 后跟一位或多位数字后跟文字文本 - 后跟一位或多位数字后跟文字文本 "。所有这些都必须以文字文本 id= 开头,但是在结果匹配中不会出现..

正在使用此模式执行 Find All in Current Document...

...匹配您在第 1、4 和 7 行列出的三个示例字符串(但不包括前面的 id=)。

编辑:

基于 this SuperUser answer (and 显示了相同的概念),我能够使以下工作正常进行:

  1. SearchReplace...Regular expression 模式下 Find what: (?<=id=)("image-\d+-\d+")Replace with: \n%%\n。单击 Replace All 按钮。
  2. SearchMark...Regular expression 模式下启用 Find what: %(.*?)%Bookmark line。单击 Mark All 按钮。
  3. SearchBookmarkRemove Unmarked Lines
  4. (可选) SearchBookmarkClear All Bookmarks