Java regex imposture re: Perl regex compatibility

A

a_c_Attlee

// 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
 
B

Betty

// 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
 
G

gimme_this_gimme_that

If you want full Perl5 regex capability, Perl style, use the Apache ORO
package.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,432
Messages
2,571,680
Members
48,796
Latest member
Greg L.

Latest Threads

Top