Escaping / in Groovy slashy syntax

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

Escaping / in Groovy slashy syntax

by graemer :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Was reading this old thread:

http://comments.gmane.org/gmane.comp.lang.groovy.jsr/870

Did anyone ever work out how to escape the / character in Groovy
slashy syntax? This:

def string = /bar\/foo/

println string

Produces:

bar\/foo

Cheers

--
Graeme Rocher
Grails Project Lead
http://grails.org

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

    http://xircles.codehaus.org/manage_email


Re: Escaping / in Groovy slashy syntax

by Jochen Theodorou :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Graeme Rocher schrieb:

> Was reading this old thread:
>
> http://comments.gmane.org/gmane.comp.lang.groovy.jsr/870
>
> Did anyone ever work out how to escape the / character in Groovy
> slashy syntax? This:
>
> def string = /bar\/foo/
>
> println string
>
> Produces:
>
> bar\/foo

looks like it is still a bug...

bye blackdrag

--
Jochen "blackdrag" Theodorou
Groovy Tech Lead (http://groovy.codehaus.org)
http://blackdragsview.blogspot.com/

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

    http://xircles.codehaus.org/manage_email


Re: Escaping / in Groovy slashy syntax

by graemer :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On 2/7/07, Jochen Theodorou <blackdrag@...> wrote:

> Graeme Rocher schrieb:
> > Was reading this old thread:
> >
> > http://comments.gmane.org/gmane.comp.lang.groovy.jsr/870
> >
> > Did anyone ever work out how to escape the / character in Groovy
> > slashy syntax? This:
> >
> > def string = /bar\/foo/
> >
> > println string
> >
> > Produces:
> >
> > bar\/foo
>
> looks like it is still a bug...

Raised:

http://jira.codehaus.org/browse/GROOVY-1698

Cheers
Graeme

>
> bye blackdrag
>
> --
> Jochen "blackdrag" Theodorou
> Groovy Tech Lead (http://groovy.codehaus.org)
> http://blackdragsview.blogspot.com/
>
> ---------------------------------------------------------------------
> To unsubscribe from this list please visit:
>
>     http://xircles.codehaus.org/manage_email
>
>


--
Graeme Rocher
Grails Project Lead
http://grails.org

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

    http://xircles.codehaus.org/manage_email


RE: Escaping / in Groovy slashy syntax

by Dierk König :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

slash = '/'
def string = /bar$slashfoo/

Dierk

> -----Original Message-----
> From: graeme.rocher@... [mailto:graeme.rocher@...]On Behalf
> Of Graeme Rocher
> Sent: Mittwoch, 7. Februar 2007 11:19
> To: user@...
> Subject: [groovy-user] Escaping / in Groovy slashy syntax
>
>
> Was reading this old thread:
>
> http://comments.gmane.org/gmane.comp.lang.groovy.jsr/870
>
> Did anyone ever work out how to escape the / character in Groovy
> slashy syntax? This:
>
> def string = /bar\/foo/
>
> println string
>
> Produces:
>
> bar\/foo
>
> Cheers
>
> --
> Graeme Rocher
> Grails Project Lead
> http://grails.org
>
> ---------------------------------------------------------------------
> To unsubscribe from this list please visit:
>
>     http://xircles.codehaus.org/manage_email

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

    http://xircles.codehaus.org/manage_email


Re: Escaping / in Groovy slashy syntax

by graemer :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Yes, but that is not very nice is it and i believe it woudl need to be

slash = '/'

def string = /bar${slash}foo/


On 2/7/07, Dierk Koenig <dierk.koenig@...> wrote:

> slash = '/'
> def string = /bar$slashfoo/
>
> Dierk
>
> > -----Original Message-----
> > From: graeme.rocher@... [mailto:graeme.rocher@...]On Behalf
> > Of Graeme Rocher
> > Sent: Mittwoch, 7. Februar 2007 11:19
> > To: user@...
> > Subject: [groovy-user] Escaping / in Groovy slashy syntax
> >
> >
> > Was reading this old thread:
> >
> > http://comments.gmane.org/gmane.comp.lang.groovy.jsr/870
> >
> > Did anyone ever work out how to escape the / character in Groovy
> > slashy syntax? This:
> >
> > def string = /bar\/foo/
> >
> > println string
> >
> > Produces:
> >
> > bar\/foo
> >
> > Cheers
> >
> > --
> > Graeme Rocher
> > Grails Project Lead
> > http://grails.org
> >
> > ---------------------------------------------------------------------
> > To unsubscribe from this list please visit:
> >
> >     http://xircles.codehaus.org/manage_email
>
> ---------------------------------------------------------------------
> To unsubscribe from this list please visit:
>
>     http://xircles.codehaus.org/manage_email
>
>


--
Graeme Rocher
Grails Project Lead
http://grails.org

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

    http://xircles.codehaus.org/manage_email


Re: Escaping / in Groovy slashy syntax

by Anthony Lauro :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

I think you can also triple quote it and then use double backslash

def string = """/bar\\/foo/"""


On 2/7/07 4:12 AM, "Graeme Rocher" <graemerocher@...> wrote:

> Yes, but that is not very nice is it and i believe it woudl need to be
>
> slash = '/'
>
> def string = /bar${slash}foo/
>
>
> On 2/7/07, Dierk Koenig <dierk.koenig@...> wrote:
>> slash = '/'
>> def string = /bar$slashfoo/
>>
>> Dierk
>>
>>> -----Original Message-----
>>> From: graeme.rocher@... [mailto:graeme.rocher@...]On Behalf
>>> Of Graeme Rocher
>>> Sent: Mittwoch, 7. Februar 2007 11:19
>>> To: user@...
>>> Subject: [groovy-user] Escaping / in Groovy slashy syntax
>>>
>>>
>>> Was reading this old thread:
>>>
>>> http://comments.gmane.org/gmane.comp.lang.groovy.jsr/870
>>>
>>> Did anyone ever work out how to escape the / character in Groovy
>>> slashy syntax? This:
>>>
>>> def string = /bar\/foo/
>>>
>>> println string
>>>
>>> Produces:
>>>
>>> bar\/foo
>>>
>>> Cheers
>>>
>>> --
>>> Graeme Rocher
>>> Grails Project Lead
>>> http://grails.org
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe from this list please visit:
>>>
>>>     http://xircles.codehaus.org/manage_email
>>
>> ---------------------------------------------------------------------
>> To unsubscribe from this list please visit:
>>
>>     http://xircles.codehaus.org/manage_email
>>
>>
>


Anthony Lauro | Senior Software Engineer
anthony.lauro@...

720 240 4510 | phone
720 240 4556 | fax
http://www.openlogic.com

OpenLogic, Inc.
Headquarters, Broomfield, Colorado 80021




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

    http://xircles.codehaus.org/manage_email


Re: Escaping / in Groovy slashy syntax

by graemer :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Yes but that defies the point of using the slashy syntax. ie you want
to have to not do double \\ to avoid quadruple \ regex escaping hell

Graeme

On 2/7/07, Anthony Lauro <anthony.lauro@...> wrote:

> I think you can also triple quote it and then use double backslash
>
> def string = """/bar\\/foo/"""
>
>
> On 2/7/07 4:12 AM, "Graeme Rocher" <graemerocher@...> wrote:
>
> > Yes, but that is not very nice is it and i believe it woudl need to be
> >
> > slash = '/'
> >
> > def string = /bar${slash}foo/
> >
> >
> > On 2/7/07, Dierk Koenig <dierk.koenig@...> wrote:
> >> slash = '/'
> >> def string = /bar$slashfoo/
> >>
> >> Dierk
> >>
> >>> -----Original Message-----
> >>> From: graeme.rocher@... [mailto:graeme.rocher@...]On Behalf
> >>> Of Graeme Rocher
> >>> Sent: Mittwoch, 7. Februar 2007 11:19
> >>> To: user@...
> >>> Subject: [groovy-user] Escaping / in Groovy slashy syntax
> >>>
> >>>
> >>> Was reading this old thread:
> >>>
> >>> http://comments.gmane.org/gmane.comp.lang.groovy.jsr/870
> >>>
> >>> Did anyone ever work out how to escape the / character in Groovy
> >>> slashy syntax? This:
> >>>
> >>> def string = /bar\/foo/
> >>>
> >>> println string
> >>>
> >>> Produces:
> >>>
> >>> bar\/foo
> >>>
> >>> Cheers
> >>>
> >>> --
> >>> Graeme Rocher
> >>> Grails Project Lead
> >>> http://grails.org
> >>>
> >>> ---------------------------------------------------------------------
> >>> To unsubscribe from this list please visit:
> >>>
> >>>     http://xircles.codehaus.org/manage_email
> >>
> >> ---------------------------------------------------------------------
> >> To unsubscribe from this list please visit:
> >>
> >>     http://xircles.codehaus.org/manage_email
> >>
> >>
> >
>
>
> Anthony Lauro | Senior Software Engineer
> anthony.lauro@...
>
> 720 240 4510 | phone
> 720 240 4556 | fax
> http://www.openlogic.com
>
> OpenLogic, Inc.
> Headquarters, Broomfield, Colorado 80021
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe from this list please visit:
>
>     http://xircles.codehaus.org/manage_email
>
>


--
Graeme Rocher
Grails Project Lead
http://grails.org

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

    http://xircles.codehaus.org/manage_email


RE: Escaping / in Groovy slashy syntax

by Dierk König :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

how about

pattern = 'bar/foo'
def string = /$pattern/

as a workaround?

Dierk

> -----Original Message-----
> From: graeme.rocher@... [mailto:graeme.rocher@...]On Behalf
> Of Graeme Rocher
> Sent: Mittwoch, 7. Februar 2007 16:06
> To: user@...
> Subject: Re: [groovy-user] Escaping / in Groovy slashy syntax
>
>
> Yes but that defies the point of using the slashy syntax. ie you want
> to have to not do double \\ to avoid quadruple \ regex escaping hell
>
> Graeme
>
> On 2/7/07, Anthony Lauro <anthony.lauro@...> wrote:
> > I think you can also triple quote it and then use double backslash
> >
> > def string = """/bar\\/foo/"""
> >
> >
> > On 2/7/07 4:12 AM, "Graeme Rocher" <graemerocher@...> wrote:
> >
> > > Yes, but that is not very nice is it and i believe it woudl need to be
> > >
> > > slash = '/'
> > >
> > > def string = /bar${slash}foo/
> > >
> > >
> > > On 2/7/07, Dierk Koenig <dierk.koenig@...> wrote:
> > >> slash = '/'
> > >> def string = /bar$slashfoo/
> > >>
> > >> Dierk
> > >>
> > >>> -----Original Message-----
> > >>> From: graeme.rocher@...
> [mailto:graeme.rocher@...]On Behalf
> > >>> Of Graeme Rocher
> > >>> Sent: Mittwoch, 7. Februar 2007 11:19
> > >>> To: user@...
> > >>> Subject: [groovy-user] Escaping / in Groovy slashy syntax
> > >>>
> > >>>
> > >>> Was reading this old thread:
> > >>>
> > >>> http://comments.gmane.org/gmane.comp.lang.groovy.jsr/870
> > >>>
> > >>> Did anyone ever work out how to escape the / character in Groovy
> > >>> slashy syntax? This:
> > >>>
> > >>> def string = /bar\/foo/
> > >>>
> > >>> println string
> > >>>
> > >>> Produces:
> > >>>
> > >>> bar\/foo
> > >>>
> > >>> Cheers
> > >>>
> > >>> --
> > >>> Graeme Rocher
> > >>> Grails Project Lead
> > >>> http://grails.org
> > >>>
> > >>>
> ---------------------------------------------------------------------
> > >>> To unsubscribe from this list please visit:
> > >>>
> > >>>     http://xircles.codehaus.org/manage_email
> > >>
> > >> ---------------------------------------------------------------------
> > >> To unsubscribe from this list please visit:
> > >>
> > >>     http://xircles.codehaus.org/manage_email
> > >>
> > >>
> > >
> >
> >
> > Anthony Lauro | Senior Software Engineer
> > anthony.lauro@...
> >
> > 720 240 4510 | phone
> > 720 240 4556 | fax
> > http://www.openlogic.com
> >
> > OpenLogic, Inc.
> > Headquarters, Broomfield, Colorado 80021
> >
> >
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe from this list please visit:
> >
> >     http://xircles.codehaus.org/manage_email
> >
> >
>
>
> --
> Graeme Rocher
> Grails Project Lead
> http://grails.org
>
> ---------------------------------------------------------------------
> To unsubscribe from this list please visit:
>
>     http://xircles.codehaus.org/manage_email


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

    http://xircles.codehaus.org/manage_email