jakarta regexp failing where jdk1.5 and gnu work fine...urgent prod issue

Mike Klein <[email protected]> Thu, 27 Jul 2006 19:02:57 -0700
Newsgroups gmane.comp.jakarta.regexp.user
Organization Virtual Appliance
Message-ID <[email protected]>
--------------040909090509080403070707
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit

I am working on an important production issue and am almost ready to
start pulling hair out.

I need to scrub emails from outgoing html and am using regexp for this.
I am stuck with regexp library for jdk 1.3 platform.

It works fine with JDK 1.5 impl and gnu-regexp...however gnu-regexp
fails when used in my appserver...so I'm trying jakarta impl. Problem is
that substitution seems broken and it's substituting OVER text that
needs to be preserved.

I will be working overnight to fix this issue and help is MUCH
appreciated...thanks.

You can see from below I am using same regexp (of course) across all 3
implementations.


mike klein


|        String newString =
theString.replaceAll("[A-Za-z0-9._%-]+@[A-Za-z0-9.-]+[.][A-Za-z]{2,4}",
"[email protected]");
        System.out.println("Using JDK 1.5....new string =
\n============\n"+newString+"============\n");

        RE re = new RE("[A-Za-z0-9._%-]+@[A-Za-z0-9.-]+[.][A-Za-z]{2,4}");
        String newString2 = re.subst(theString, "[email protected]");
        System.out.println("Using jakarta....new string =
\n============\n"+newString2+"============\n");

        try
        {
            gnu.regexp.RE re2 = new
gnu.regexp.RE("[A-Za-z0-9._%-]+@[A-Za-z0-9.-]+[.][A-Za-z]{2,4}");
            String newString3 = re2.substituteAll(theString, "[email protected]");
            System.out.println("Using gnuregexp....new string =
\n============\n"+newString3+"============\n");
        }
        catch(Exception x)
        {
            System.out.println(x);
            System.exit(0);
        }



C:\projects\regexp>java -cp
jakarta-regexp-1.4.jar;gnu-regexp-1.1.4.jar;. regexp
Read in file:
=============
foo@bar
[email protected]
foo
[email protected]
 [email protected] [email protected]       [email protected]
<a>[email protected]</a>

=============

Using JDK 1.5....new string =
============
foo@bar
[email protected]
foo
[email protected]
 [email protected] [email protected]       [email protected]
<a>[email protected]</a>
============

Using jakarta....new string =
============
foo@bar
[email protected]
foo
[email protected]
 [email protected] [email protected]       [email protected]
[email protected]</a>
============

Using gnuregexp....new string =
============
foo@bar
[email protected]
foo
[email protected]
 [email protected] [email protected]       [email protected]
<a>[email protected]</a>
============

|

--------------040909090509080403070707--