Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 80666

Summary: [find/replace] regex should support \R for any linebreak
Product: [Eclipse Project] Platform Reporter: Markus Keller <markus.kell.r>
Component: TextAssignee: Platform-Text-Inbox <platform-text-inbox>
Status: RESOLVED FIXED QA Contact:
Severity: enhancement    
Priority: P3 Keywords: helpwanted
Version: 3.1   
Target Milestone: 3.4 M1   
Hardware: PC   
OS: Windows XP   
Whiteboard:

Description Markus Keller CLA 2004-12-10 03:20:24 EST
Find/Replace in regex mode should support the pattern \R, where \R matches a
linebreak in the current document's format. \R is proposed in this unicode
document, which is linked from java.util.regex.Pattern's javadoc:
http://www.unicode.org/unicode/reports/tr18/

The implementation could just replace \R in the find pattern by the document's
line delimiter.
Comment 1 Dani Megert CLA 2004-12-10 03:37:25 EST
Not for 3.1
Comment 2 Markus Keller CLA 2007-06-18 05:08:02 EDT
> The implementation could just replace \R in the find pattern by the document's
> line delimiter.

This will not work in all cases. E.g. for a Windows (\r\n) file, there's no straightforward way to replace \R in an expression like [x\R]\t, since character sets (in []) can only match single characters.

However, we could just replace \R with (?:\r\n?|\n) (a non-capturing group that matches any line delimiter) outside of characters sets and throw a PatternSyntaxException in case \R is used inside a character set (similar to what happens for e.g. (.)[\1]. That would solve most real cases and not try to solve the unsolvable.

See also bug 52338 and bug 80667.
Comment 3 Dani Megert CLA 2007-07-15 10:33:26 EDT
Thanks Markus.
Patch committed to HEAD.
Available in builds > N20070715-0010.