使用Aptana Studio 3我使用^(.+)$
成功捕获了文本行,并使用<p>\1</p>
替换了找到的表达式。
例如:
This is a line of text.
会产生<p>This is a line of text.</p>
但是,当我尝试将Note - this is a line of text
中的“注释”替换为<strong>Note</strong>
时。
^(.+)(?= -)
选择上面示例中“ - ”(单词“Note”)之前的所有文字,但
&LT;强&GT; \ 1·/强&GT;
不会将其替换为<strong>Note</strong>
在尝试了一些在线资源后,我得到了&lt; strong&gt; $ 0&lt; / strong&gt;在线工作但不在Aptana工作。有人有解决方案吗?
顺便说一下,“Note”是我能提供的最简洁的例子。许多行包含“ - ”之前的多字短语。
答案 0 :(得分:2)
有什么奇怪的! Aptana似乎不允许在使用前瞻(可能是一个bug)时进行任何替换,但无论如何都要匹配。我在Aptana Studio 3上重现了它,版本:3.4.0.201304151603。请注意,lookbehind没有问题。
您可以使用:
find: ^(.+)( -)
replace: <strong>\1</strong>\2
[编辑]
这是一个知道错误:Eclipse regex search/replace not replacing after regex positive look-ahead?