Java regex imposture re: Perl regex compatibility

Discussion in 'Java' started by a_c_Attlee@yahoo.com, May 5, 2005.

  1. Guest

    // 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
     
    , May 5, 2005
    #1
    1. Advertising

  2. Betty Guest

    <> wrote in message
    news:...
    > // 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
     
    Betty, May 5, 2005
    #2
    1. Advertising

  3. Guest

    If you want full Perl5 regex capability, Perl style, use the Apache ORO
    package.
     
    , May 6, 2005
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Rick Venter

    perl regex to java regex

    Rick Venter, Oct 29, 2003, in forum: Java
    Replies:
    5
    Views:
    1,634
    Ant...
    Nov 6, 2003
  2. Replies:
    3
    Views:
    770
    Reedick, Andrew
    Jul 1, 2008
  3. Tammo Tjarks
    Replies:
    3
    Views:
    120
    Wolfgang Nádasi-Donner
    Sep 9, 2007
  4. \Dandy\ Randy

    File type compatibility issue with Perl

    \Dandy\ Randy, Jul 28, 2003, in forum: Perl Misc
    Replies:
    3
    Views:
    100
    Garry Short
    Jul 28, 2003
  5. Alex F.
    Replies:
    2
    Views:
    128
    H. Merijn Brand
    Feb 23, 2004
Loading...

Share This Page