Pergunta

I have a multi-line string

Some test
String
Here

I am using this regex pattern to find it (Some\s.*)(.|\n)* & replace it with \1\2

Instead of getting the same text back, I get

Some test e

Why isn't the second backreference working? Is there a better way to specify multiline in regex rather than (.|\n)*

PS : Using Sublime Text 2 on Windows

Update : I see my mistake after reading Jerry's answer.

Foi útil?

Solução

(.|\n)*

In this captured group, you'll get only the last match. You could try using this instead:

((?:.|\n)*)

Or if you want to match everything you could possibly use something like:

([\s\S]*)
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top