Uploaded image for project: 'Groovy'
  1. Groovy
  2. GROOVY-9019

triple-single and triple-double quotes handle backslash escapes equally

    XMLWordPrintableJSON

    Details

    • Type: Documentation
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 3.0.0-beta-1, 2.5.7
    • Component/s: Documentation
    • Labels:
      None

      Description

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

       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)
      

      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.

       

      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}"
      

       

      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
      

       

       

        Attachments

          Activity

            People

            • Assignee:
              paulk Paul King
              Reporter:
              ilatypov Ilguiz Latypov
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: