Re: reg Exp doubt
Oleg Sukhodolsky <[email protected]> Fri, 10 Oct 2003 23:15:18 +0400
| Newsgroups | gmane.comp.jakarta.regexp.user |
|---|---|
| Message-ID | <[email protected]> |
Hi Jeevan,
> I want to match a string like "abc 123 pqr" and substitute "abc " with "XYZ "
> Anything after "abc " can come in the new line.
> i wrote a Reg Expr
> RE re1 = new RE("<!abc [^\s]*",RE.MATCH_CASEINDEPENDENT );
> this gives me complier error "illegal escape character"
This is because Java considers \s as escape character inside string
literal. You should write \\s (double slash represents one slash)
> I tried another one
> RE re1 = new RE("<!abc [^[:space:]]*",RE.MATCH_CASEINDEPENDENT );
> this gives me run time error
I think this is because of [^[:class:]] you can use (^[:class:])*
instead.
And by the way I think that jakarta-regexp doesn't support "<!"
construction.
With best regards, Oleg.