You are viewing a plain text version of this content. The canonical link for it is here.
Posted to regexp-user@jakarta.apache.org by Mike Klein <mi...@sbcglobal.net> on 2006/07/28 04:02:57 UTC
jakarta regexp failing where jdk1.5 and gnu work fine...urgent prod
issue
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}",
"X@X.X");
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, "X@X.X");
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, "X@X.X");
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
mklein@vxapp.com
foo
mklein@vxapp.com
mklein@vxapp.com baby@bar.com baby@bar.foo
<a>mklein@vxapp.com</a>
=============
Using JDK 1.5....new string =
============
foo@bar
X@X.X
foo
X@X.X
X@X.X X@X.X X@X.X
<a>X@X.X</a>
============
Using jakarta....new string =
============
foo@bar
X@X.X
foo
X@X.X
X@X.X X@X.X X@X.X
X@X.X</a>
============
Using gnuregexp....new string =
============
foo@bar
X@X.X
foo
X@X.X
X@X.X X@X.X X@X.X
<a>X@X.X</a>
============
|