我遇到一个文章,需要把所有的 (数字) 换为 [数字]
于是我使用 Sublime Text的替换
首先,我们需要打开正则使用“Alt+R” 或打开“Ctrl+h”选择正则。
然后我们开始输入正则,“ ((d+) ” 我们需要拿出的是数字,所有在数字加“()”。于是在替换写“[<nobr><span class="math" id="MathJax-Span-15" style=" 5.176em; display: inline-block;"><span style="display: inline-block; position: relative; 4.109em; height: 0px; font-size: 125%;"><span style="position: absolute; clip: rect(1.816em 1000em 3.149em -0.371em); top: -2.771em; left: 0.003em;"><span class="mrow" id="MathJax-Span-16"><span class="mn" id="MathJax-Span-17" style="font-family: MathJax_Main;">1</span><span id="MathJax-Color-18" style="display: inline-block; background-color: rgb(255, 238, 238); 0.696em; height: 1.016em; vertical-align: -0.264em; margin-left: -0.051em; margin-right: -0.637em;"></span><span class="mtext" id="MathJax-Span-18" style="font-size: 90%; font-family: MathJax_Main; color: red;">]</span><span class="mo" id="MathJax-Span-19" style="font-family: MathJax_Main;">”</span><span class="texatom" id="MathJax-Span-20"><span class="mrow" id="MathJax-Span-21"><span class="mo" id="MathJax-Span-22"><span style='font-family: STIXGeneral, "Arial Unicode MS", serif; font-size: 80%; font-style: normal; font-weight: normal;'>,</span></span></span></span><span class="texatom" id="MathJax-Span-23"><span class="mrow" id="MathJax-Span-24"><span class="mo" id="MathJax-Span-25"><span style='font-family: STIXGeneral, "Arial Unicode MS", serif; font-size: 80%; font-style: normal; font-weight: normal;'>其</span></span></span></span><span class="texatom" id="MathJax-Span-26"><span class="mrow" id="MathJax-Span-27"><span class="mo" id="MathJax-Span-28"><span style='font-family: STIXGeneral, "Arial Unicode MS", serif; font-size: 80%; font-style: normal; font-weight: normal;'>中</span></span></span></span></span><span style="display: inline-block; 0px; height: 2.776em;"></span></span></span><span style="border-left: 0.003em solid; display: inline-block; overflow: hidden; 0px; height: 1.403em; vertical-align: -0.33em;"></span></span></nobr><script type="math/tex" id="MathJax-Element-2">1]”,其中</script>0就是所有的,$1就是第一个括号。
如何使用正则可以去看正则表达入门。
Sumlime 还可以创建代码行,做法也很简单。
点击 Tools New Snippet
< snippet>
< content><![CDATA[
Hello, ${1:this} is a ${2:snippet}.
]]>< /content>
<!-- Optional: Set a tabTrigger to define how to trigger the snippet -->
<!-- <tabTrigger>hello</tabTrigger> -->
<!-- Optional: Set a scope to limit where the snippet will trigger -->
<!-- <scope>source.python</scope> -->
< /snippet>
content 是我们按下快捷键的内容,$ {1:this} 就是第一个输入内容,其中,默认写This,所有的{1}都代换你输入的第一个。$2就是第二个。
我们需要设置快捷键。
<tabTrigger>hello</tabTrigger>
就是按下 hello,按下 tab 就会使用代码段。
写好,我们保存在C:Users<Use>AppDataRoamingSublime Text 2PackagesUser
后缀.sublime-snippet
我们有时打开中文会乱码,我们可以 ctrl+shift+p
输入 Package control:install 安装 CovertToUTF8