You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@groovy.apache.org by "Ilguiz Latypov (JIRA)" <ji...@apache.org> on 2019/03/05 17:50:00 UTC

[jira] [Updated] (GROOVY-9019) triple-single and triple-double quotes handle backslash escapes equally

     [ https://issues.apache.org/jira/browse/GROOVY-9019?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Ilguiz Latypov updated GROOVY-9019:
-----------------------------------
    Description: 
The documentation implies that triple-single quotes treat only escaping of single quotes with backslashes. 
{code:java}
 315 |'\''
 316 |single quote (for single quoted and triple single quoted strings)
 317
 318 |'\"'
 319 |double quote (for double quoted and triple double quoted strings)
{code}
[https://gitbox.apache.org/repos/asf?p=groovy.git;a=blob;f=src/spec/doc/core-syntax.adoc;h=30b48fdfb4caafacae343f5dac9dde3372da65b2;hb=HEAD#l315]

 

My quick tests show that regardless of the surrounding triple quotes, backslash escaping works equally on single and double quotes.

 
{code:java}
s = '''foo\"bar'''
println "The triple-single-quoted string with a backslash-double-quote inside: ${s}"
s = """foo\'bar"""
println "The triple-double-quoted string with a backslash-single-quote inside: ${s}"
{code}
  
{code:java}
The triple-single-quoted string with a backslash-double-quote inside: foo"bar
The triple-double-quoted string with a backslash-single-quote inside: foo'bar
{code}
 

 

  was:
The documentation implies that triple-single quotes treat only escaping of single quotes with backslashes. 

 
{code:java}
|'\''
 316 |single quote (for single quoted and triple single quoted strings)
 317
 318 |'\"'
 319 |double quote (for double quoted and triple double quoted strings)
{code}
[https://gitbox.apache.org/repos/asf?p=groovy.git;a=blob;f=src/spec/doc/core-syntax.adoc;h=30b48fdfb4caafacae343f5dac9dde3372da65b2;hb=HEAD#l315]

 

My quick tests show that regardless of the surrounding triple quotes, backslash escaping works equally on single and double quotes.

 
{code:java}
s = '''foo\"bar'''
println "The triple-single-quoted string with a backslash-double-quote inside: ${s}"
s = """foo\'bar"""
println "The triple-double-quoted string with a backslash-single-quote inside: ${s}"
{code}
 

 

 
{code:java}
The triple-single-quoted string with a backslash-double-quote inside: foo"bar
The triple-double-quoted string with a backslash-single-quote inside: foo'bar
{code}
 

 


> triple-single and triple-double quotes handle backslash escapes equally
> -----------------------------------------------------------------------
>
>                 Key: GROOVY-9019
>                 URL: https://issues.apache.org/jira/browse/GROOVY-9019
>             Project: Groovy
>          Issue Type: Documentation
>          Components: Documentation
>            Reporter: Ilguiz Latypov
>            Priority: Minor
>
> The documentation implies that triple-single quotes treat only escaping of single quotes with backslashes. 
> {code:java}
>  315 |'\''
>  316 |single quote (for single quoted and triple single quoted strings)
>  317
>  318 |'\"'
>  319 |double quote (for double quoted and triple double quoted strings)
> {code}
> [https://gitbox.apache.org/repos/asf?p=groovy.git;a=blob;f=src/spec/doc/core-syntax.adoc;h=30b48fdfb4caafacae343f5dac9dde3372da65b2;hb=HEAD#l315]
>  
> My quick tests show that regardless of the surrounding triple quotes, backslash escaping works equally on single and double quotes.
>  
> {code:java}
> s = '''foo\"bar'''
> println "The triple-single-quoted string with a backslash-double-quote inside: ${s}"
> s = """foo\'bar"""
> println "The triple-double-quoted string with a backslash-single-quote inside: ${s}"
> {code}
>   
> {code:java}
> The triple-single-quoted string with a backslash-double-quote inside: foo"bar
> The triple-double-quoted string with a backslash-single-quote inside: foo'bar
> {code}
>  
>  



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)