Short answer:
I decided to use \s++
as separator in multi-line search expressions (with regular expressions enabled) and \Qfoo\E
to escape special characters if required.
Long answer:
As soru
already answered, for any "Unicode linebreak sequence" a regular expression search with \R
can be used.
A pure carriage return is represented by \r
. Upper and lower case make a difference. \R represents any unicode linebreak sequence (for example \r\n).
I found this SO question because I wanted to search for a multi-line expression in Eclipse, including line breaks and tabs:
@Override
@Transient
In order to include the white spaces in my regular search expression I used (on Windows platform)
@Override\r\n\t*@Transient
Following expressions also work:
@Override\R\t*@Transient
@Override\s++@Transient
Please note that the second expression also matches @Override @Transient
without a line break, which is fine for me.
Following expressions did not! work for me:
@Override\r\t*@Transient
@Override\n\t*@Transient
Explanation of some regular expressions:
\R
represents any unicode linebreak sequence (for example \r\n
)
\s
represents any white space
\t
represents a tab
*
matches zero or more occurrences
++
matches one ore more occurrences
\Q
and \E
escape wrapped content. Use them if your original multi line expression includes special regex characters, for example
\Q/**\E\s++\Q*\E
matches
/**
*
Also see:
Difference between \n and \r?
https://docs.oracle.com/javase/7/docs/api/java/util/regex/Pattern.html