Java regex imposture re: Perl regex compatibility  
Author Message
a_c_Attlee





PostPosted: 2005-5-6 3:46:00 Top

java-programmer, Java regex imposture re: Perl regex compatibility // java has claimed to have added Perl style regular expressions ,
however
// writing a regular expression containing a variable is ugly in java.
// in Perl: $rec =~ s/$delimiter//g is easy to write and to read.
// in java: if delimiter may hold say "||" or "!" isntead of [a-z]
text,
// you have to quote it as below with preceding \\Q (not just \Q ) and
// trailing \\E. ugly and difficult to code!

rec = rec.replaceAll("\\Q" + delimiter + "\\E" ,"");

So even though java has perl style regex in principle, in practice,
in java they seem nearly unusable!

-A.C. Attlee

 
Betty





PostPosted: 2005-5-6 6:00:00 Top

java-programmer >> Java regex imposture re: Perl regex compatibility
<email***@***.com> wrote in message
news:email***@***.com...
> // java has claimed to have added Perl style regular expressions ,
> however
> // writing a regular expression containing a variable is ugly in java.
> // in Perl: $rec =~ s/$delimiter//g is easy to write and to read.
> // in java: if delimiter may hold say "||" or "!" isntead of [a-z]
> text,
> // you have to quote it as below with preceding \\Q (not just \Q ) and
> // trailing \\E. ugly and difficult to code!
>
> rec = rec.replaceAll("\\Q" + delimiter + "\\E" ,"");
>
> So even though java has perl style regex in principle, in practice,
> in java they seem nearly unusable!
>
> -A.C. Attlee
sissy


 
gimme_this_gimme_that





PostPosted: 2005-5-6 8:16:00 Top

java-programmer >> Java regex imposture re: Perl regex compatibility If you want full Perl5 regex capability, Perl style, use the Apache ORO
package.