[英]Notepad++: Multiple line search & multiple line replace
I'm having a battle with a regex. 我正在与正则表达式进行斗争。 (MOBI creation) I have two files: one with XML, the other an HTML table of contents. (创建MOBI)我有两个文件:一个包含XML,另一个包含HTML目录。
The important parts of the XML: XML的重要部分:
<navPoint id="_NeedsHTMLid" playOrder="40">
<navLabel><text>Needs anchor text from link.)</text></navLabel>
...
The HTML TOC, of course, looks like: schema.org Article Mark-up HTML TOC当然看起来像:schema.org文章标记
====== Hours and hours... worked with Textpad forever. ======小时数小时...永远与Textpad一起工作。 Saw remarks here, now I'm using NotePad++... some of the regex results are different (NOT that I had it working anyway.) #_[\\b(\\w\\b]
was returning the ID: now? Not so much! 在这里看到了注释,现在我使用的是NotePad ++ ...一些正则表达式的结果是不同的(不是我无论如何都可以。) #_[\\b(\\w\\b]
返回ID:现在吗?许多!
Does anyone know how to yank both the ID and the anchor text out of these? 有谁知道如何从中提取ID和锚文本? I'd be so grateful. 我会非常感激。
#_[\\b(\\w\\b]
is not a valid regex. Try _([^"]+)\\b
. #_[\\b(\\w\\b]
不是有效的正则表达式。请尝试_([^"]+)\\b
。
Edited: try [^"]
in place of \\w
. 编辑:尝试用[^"]
代替\\w
。
You can use this to get the id and the anchor text at the same time: 您可以使用它同时获取ID和锚文本:
_(\\w+)\\b|([aZ\\s.]+[)]+) _(\\ w +)\\ b |([aZ \\ s。] + [)] +)
If you want to match the ids and the text, go to Search
> Find
menu (shortcut CTRL + F ) and do the following: 如果要匹配ID和文本,请转到“ Search
>“ Find
菜单(快捷键CTRL + F ),然后执行以下操作:
Find what: 找什么:
id="([a-zA-Z0-9\\-\\:\\_\\.]+)"|<text>(.+?)<\\/text>
Select radio button "Regular Expression" 选择单选按钮“正则表达式”
Then press Find All in Current Document
然后按Find All in Current Document
You can test it with your example at regex101 . 您可以在regex101上通过示例进行测试 。
Here's a StackOverflow post about valid id names. 这是有关有效ID名称的StackOverflow帖子。
I didn't provided you with a Search and Replace solution, since you didn't mentioned anything about a replacement. 我没有为您提供“搜索并替换”解决方案,因为您没有提及任何有关替换的内容。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.