Вопрос

I have several .txt files I must modify:

every

\(
\blabla

must become

\begin{equation*}
\blabla

notepad++ does find \\( when I use \\(\r. But when I input \\(\r\blabla it does not find anything. I am a noob at regexp.

Это было полезно?

Решение

To match newlines, you need a \n in some places, and \r in others. I'm not sure about which to use when either, but if the one doesn't work, try the other. In your case, use this:

\\(\n\\blabla

Другие советы

You can also use "Extended Search" option in "Search Mode" section. This will detect \r correctly. Enter search string as \(\r.

Strictly speaking, you should use something like (?:\r\n|[\r\n]) to match any of the three most common line endings, \n (Unix), \r\n (DOS/Windows) or \r alone (pre-OSX Mac). In this case I think it's safe to assume the line endings are all \r\n or all \n, which you can match with \r?\n.

But you have a better option: \v, the vertical whitespace shorthand. It will match a carriage return or linefeed, but not spaces or tabs. This works for me in NPP v6.5.5:

\\(\v+\\blabla

I'm assuming you want \\b to match a backslash followed by b, not a word boundary.

If you want to match any line break, use \R. And, as Alan Moore said, to match a backslash \ followed by a b, use \\b:

\\(\R\\blabla

\R matches \r or \n or \r\n

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top