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 Giovanni Azua <ga...@kdlabs.com> on 2004/11/10 16:50:00 UTC

how to escape forward slash?

Hello 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 terminates string
...
PATTERN ERROR in line: / C\/O / /

Thanks in advance,

Best Regards,
Giovanni

---------------------------------------------------------------------
To unsubscribe, e-mail: regexp-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: regexp-user-help@jakarta.apache.org


Re: how to escape forward slash?

Posted by Don Vawter <do...@vawter.com>.
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:

>Hello 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 terminates string
>...
>PATTERN ERROR in line: / C\/O / /
>
>Thanks in advance,
>
>Best Regards,
>Giovanni
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: regexp-user-unsubscribe@jakarta.apache.org
>For additional commands, e-mail: regexp-user-help@jakarta.apache.org
>
>  
>


---------------------------------------------------------------------
To unsubscribe, e-mail: regexp-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: regexp-user-help@jakarta.apache.org


Re: how to escape forward slash?

Posted by Michael McCallum <gh...@xtra.co.nz>.
Hi, 
The problem will be that whatever is parsing your thesaurus (text file) is not 
escaping the / so it only passes " C\" to regexp rather than " C/O / " as you 
desired. Hence the string is terminated with an escape, which is invalid.

kind regards

Michael

On Thu, 11 Nov 2004 04:50, Giovanni Azua wrote:
|  Hello 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 terminates
| string ...
|  PATTERN ERROR in line: / C\/O / /
|
|  Thanks in advance,
|
|  Best Regards,
|  Giovanni
|
|  ---------------------------------------------------------------------
|  To unsubscribe, e-mail: regexp-user-unsubscribe@jakarta.apache.org
|  For additional commands, e-mail: regexp-user-help@jakarta.apache.org

-- 
Michael McCallum
Software Engineering Manager
SnapHire Inc
land: +64.9.308.0329
cell: +64.21.576.907
http://www.SnapHire.com/



---------------------------------------------------------------------
To unsubscribe, e-mail: regexp-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: regexp-user-help@jakarta.apache.org