在重复文本前后添加括号的正则表达式 [英] regular expression to add brackets before and after a repeated text

查看:73
本文介绍了在重复文本前后添加括号的正则表达式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有下面这行,我想在它前后加一个括号:

来自:

<块引用>

马特.XX.19.

或:

<块引用>

1 论文.一世.7.

和不同的经文引用值..(换句话说,在那些 > 和 <

之间的任何东西

到:

<块引用>

(马特 xx. 19.)</span>

等等(它需要介于 > 和 < 之间的任何内容,并在其前后添加 () ..

ps.我用记事本++来搜索和替换..

  • 前 3 个回复效果很好,即使对于任何与经文格式不同的内容..这很有帮助..但是我在代码中注意到了一些没有改变的差异..就像代码之间有任何标签一样.. 喜欢:

    [参见<i>Dan</i>,注释12,p.26,<i>以下</i>.永恒"=长"]</span>

或者如果代码被分成多行!喜欢

<块引用>

一些文字更多文字</span>

提前致谢,

解决方案

搜索

\s*([^<>]*?)\s*</span>

并替换为

(\1)

改变了

马特.XX.19. </span>

进入

(Matt. xx. 19.)

I have the following line, and I want to add a brackets before and after it:

from:

<span class="Footnote">    Matt. xx. 19.</span>

or:

<span class="Footnote">    1 Thess. i. 7.</span>

and different values of verse references.. (in other words anything in between those > and <

to:

<span class="Footnote"> (Matt. xx. 19.)</span>

and so on (it takes anything in between those > and < and add () before and after it..

p.s. I use notepad++ to search and replace..

  • edit: the first 3 replies work great, even for anything not in the same format of the verse.. which is helpful.. however I noticed in the code some differences that doesn't get changed.. like if the code has any tags in between.. like:

    <span class="Footnote">    [See <i>Dan</i>, note 12, p. 26, <i>infra</i>.  "Eternal" ="long."]</span>

or if the code is divided in more than one line! like

<span class="Footnote">    some text

more text

</span>

Thanks in advance,

解决方案

Search for

<span class="Footnote">\s*([^<>]*?)\s*</span>

and replace with

<span class="Footnote">(\1)</span>

This changes

<span class="Footnote">    Matt. xx. 19.  </span>

into

<span class="Footnote">(Matt. xx. 19.)</span>

这篇关于在重复文本前后添加括号的正则表达式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆