0

以下是我长文的摘录:

As a young researcher, he is required:
\n ÷ to read at least three theses\n ÷ to meet his tutor or supervisor 
once a week\n ÷ to join seminars\n

现在我想找到任何以 开头÷和结尾的块,\n并替换÷÷<font color="blue">\n</font>\n因此,例如,我上面的摘录将如下所示:

As a young researcher, he is required:
\n ÷<font color="blue"> to read at least three theses</font>\n ÷<font color="blue"> 
to meet his tutor or supervisor once a week</font>\n ÷<font color="blue"> to join seminars</font>\n

到目前为止,我一直在 TextWrangler 中使用这些 Grep 来查找和替换:

(÷[^ \t/<>]*?).*?([^ \t/<>]*?\\n)

<font color="blue">\1\2</font>\3

已成功找到所需的文本块,但替换不像我预期的那样工作。

我正在使用 TextWrangler,但可以访问 BBEdit 或 Notepad++。

你能帮我解决这个问题吗?非常感谢你。


更新

感谢 DesertEagle,我已经找到了解决方案。这是代码:

÷([^\\n]+)\\n
÷<font color="blue">\1</font>\\n
4

1 回答 1

1

虽然我手头没有 textwrangler,但这应该适合你 [1]

搜索 /÷([^\n]+)\n/

编辑 textwrangler 的正确语法是 ÷([^\\n]+)\\n

代替 ÷<font color="blue">\1</font>\n

[1] please ensure proper escaping for your engine

于 2012-08-15T15:52:26.830 回答