Q: slashes in slash strings

View: New views
3 Messages — Rating Filter:   Alert me  

Q: slashes in slash strings

by grkuntzmd :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

If I want to include slashes ('/') in slash-quoted strings, do I need to escape them with backslashes? In other words, if I need to create a Regex that matches a *nix-like path, should I use /x\/y/ or /x/y/?

Thanks.

G. Ralph Kuntz, MD

Re: Q: slashes in slash strings

by Alex Greif :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

I think you cannot use slashy strings in this case. Try it with
pattern Strings like this:
groovy:000> p = ~"/home/me/"
===> /home/me/
groovy:000> p.class
===> class java.util.regex.Pattern

Alex.

On Thu, Aug 21, 2008 at 1:40 PM, grkuntzmd <grk@...> wrote:

> If I want to include slashes ('/') in slash-quoted strings, do I need to
> escape them with backslashes? In other words, if I need to create a Regex
> that matches a *nix-like path, should I use /x\/y/ or /x/y/?
>
> Thanks.
>
> G. Ralph Kuntz, MD
> Chief Software Architect
> meridianEMR, Inc.
> ________________________________
> View this message in context: Q: slashes in slash strings
> Sent from the groovy - user mailing list archive at Nabble.com.
>

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email



Re: Q: slashes in slash strings

by Robert Fletcher :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Yes, you can escape them. They're just another string delimiter, they
don't mean anything special in relation to regular expressions. If
you're using regex matching on paths like that I'd consider using
single or double quote delimiters as the regex string will be much
more readable.

On Thu, Aug 21, 2008 at 12:40 PM, grkuntzmd <grk@...> wrote:
> If I want to include slashes ('/') in slash-quoted strings, do I need to
> escape them with backslashes? In other words, if I need to create a Regex
> that matches a *nix-like path, should I use /x\/y/ or /x/y/?
>

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email