Ok, the following code works using the regexp library:
import org.apache.regexp.*; public class Test { public static void main (String[] argv){ try{ String s = "A|b|c|d|e C/O \naaa\n\n\nSS|S"; String re = "C[/]O"; if(argv.length > 0) { re=argv[0]; } if(argv.length > 1) { s=argv[1]; } RE r = new RE(re); String o= r.subst(s,"xxx"); System.out.println(o); } catch (Exception e){ System.out.println(e.getMessage()); }
System.exit(0); } }
This works with either C/O or C[/]O
Maybe I don't understand what you are trying to do but this replaces all occurences of C/O with xxx
You can try it with java Test <re> <StringToApply>
Giovanni Azua wrote:
Hello Vawter,
It does not work for me, I tried exactly that already.
But I do not understand what you mean by 1.42??? since jakarta regexp latest release is 1.3 ...
if you mean 1.4x as JSE then I would not be using
jakarta regexp at all, I need regexp jakarta because
I am tied to using JVM 1.3x only.
Additionally I can not hardcode the replacing within the java code because we have a large list
of transformation patterns that must be updateable without having to modify, recompile and redeploy the
java files, the transformation patterns (thesaurus) is included separately as a text (configuration) file.
Thanks in advance, Best Regards, Giovanni
-----Original Message----- From: Don Vawter [mailto:[EMAIL PROTECTED] Sent: Wednesday, November 10, 2004 5:18 PM To: Regexp Users List Subject: Re: how to escape forward slash?
I think you can use:
/ C[/]O / /
I haven't tested this but in 1.42 s.replaceAll("C/O","xxx") works fine
I haven't tested th
Giovanni Azua wrote:
terminates stringHello all,
Does anyone know how to escape forward slash using jakarta regexp, the funny thing is that sed understand well the escaping of forward slash: \/ but regexp does not.
e.g. when providing the pattern:
/ C\/O / /
I get the following error:
org.apache.regexp.RESyntaxException: Syntax error: Escape
... PATTERN ERROR in line: / C\/O / /
Thanks in advance,
Best Regards, Giovanni
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]