6 html regex notepad++ calibre
我有一个html菜单文件,其中包含由chm解码器提取的html页面列表.
(7,0,"Icons Used in This Book","final/pref04.html");
(8,0,"Command Syntax Conventions","final/pref05.html");
(9,0,"Introduction","final/pref06.html");
(10,0,"Part I: Introduction and Overview of Service","final/part01.html");
(11,10,"Chapter 1. Overview","final/ch01.html");
(12,11,"Technology Motivation","final/ch01lev1sec1.html");
Run Code Online (Sandbox Code Playgroud)
我希望从这个创建Caliber的"目录"文件(HTML文件包含所需顺序的所有其他文件的链接).最终文件应如下所示:
<a href="final/pref04.html">Icons Used in This Book</a><br/>
<a href="final/pref05.html">Command Syntax Conventions</a><br/>
.
.
.
Run Code Online (Sandbox Code Playgroud)
所以首先我需要删除带有正则表达式的数字前缀,然后添加a href
属性来制作超链接,并更改URL和标题位置.任何人都可以用Notepad ++展示如何制作这个吗?
我想这会为你做,我是基于Mac的,所以我没有notepad ++但是这在Dreamweaver中有效.假设每个表达式都是基于一行的.
找:
\(.*?"(.*?)","(.*?)".*
Run Code Online (Sandbox Code Playgroud)
更换:
<a href="$2">$1</a><br/>
Run Code Online (Sandbox Code Playgroud)
文件:
(7,0,"Icons Used in This Book","final/pref04.html");
(8,0,"Command Syntax Conventions","final/pref05.html");
(9,0,"Introduction","final/pref06.html");
(10,0,"Part I: Introduction and Overview of Service","final/part01.html");
(11,10,"Chapter 1. Overview","final/ch01.html");
(12,11,"Technology Motivation","final/ch01lev1sec1.html");
Run Code Online (Sandbox Code Playgroud)
全部替换后:
<a href="final/pref04.html">Icons Used in This Book</a><br/>
<a href="final/pref05.html">Command Syntax Conventions</a><br/>
<a href="final/pref06.html">Introduction</a><br/>
<a href="final/part01.html">Part I: Introduction and Overview of Service</a><br/>
<a href="final/ch01.html">Chapter 1. Overview</a><br/>
<a href="final/ch01lev1sec1.html">Technology Motivation</a><br/>
Run Code Online (Sandbox Code Playgroud)
如果不是基于变化一行.*
到.*?\n
.这应该会在每个换行后停止.为了便于阅读,您还可能需要为替换添加换行符.
如果你想修改它,也应该解释正则表达式...
第一个\
是逃避,(
因此正则表达式知道寻找文字字符和非特殊的正则表达式分组.该*?
说找到的每一个字符,直到第一个"
; (.
是任何单个字符,*
是前一个字符的零次或多次出现,并?
告诉它在第一次出现下一个字符时停止"
).最后.*
说继续搜索.该组(
及其)
周围.*?
发现的价值进入$1
和$2
.该数字与正则表达式中的顺序相关.