United StatesChange Country, Oracle Worldwide Web Sites Communities I am a... I want to...
Bug ID: 5092855 RFE:Change language specification for easier writing of Regular Expressions
5092855 : RFE:Change language specification for easier writing of Regular Expressions

Details
Type:
Enhancement
Submit Date:
2004-08-26
Status:
Open
Updated Date:
2006-11-17
Project Name:
JDK
Resolved Date:
Component:
specification
OS:
linux
Sub-Component:
language
CPU:
x86
Priority:
P4
Resolution:
Unresolved
Affected Versions:
1.4.2
Targeted Versions:

Related Reports
Relates:
Relates:
Relates:

Sub Tasks

Description
Name: rmT116609			Date: 08/26/2004


A DESCRIPTION OF THE REQUEST :
The intention of this proposed change is to make writing regular expressions more straightforward and more Perl-like. Writing a regular expression in Java is, besides thinking about logic, also about adding a lot of backslashes.

Instead of the double quote I suggest to use the back quote (what's in a name), and also a  RegexString object that extends the String object.
Examples:
"\\(.*?\\)" .equals(`\(.*?\)`);
`\(hello\)`.equals("\\(hello\\)");
Pattern p = Pattern.compile(`\s+\d+`);

JUSTIFICATION :
Although escaping special characters with a backslash is in the Java Language Specification, the result is that regular expressions  become less readable and maintainable. To get rid of the extra backslashes I suggest to create this new String-like object that handles backslashes more gracefully.
(Incident Review ID: 237231) 
======================================================================

                                    

Comments
EVALUATION

One of numerous requests for easier handling of literals.
                                     
2006-11-17



Hardware and Software, Engineered to Work Together