String in Groovy
In Groovy there are 6 types of strings. The differences among them are as below table.
Type | Gramma | Variable Translation | Multiple Line | Escape |
---|---|---|---|---|
Single Quoted | '...' |
No | No | \ |
Triple Quoted | '''...''' |
No | Yes | \ |
Double Quotation Mark | "..." |
Yes | No | \ |
3 Double Quotation Marks | """...""" |
Yes | Yes | \ |
Slashy | /.../ |
Yes | Yes | \ |
Dollar Slashy | $/...$/ |
Yes | Yes | $ |
Escaped Characters
In Java, the following characters need to be escaped[1]:
* Quotation marks "
* Backslash \
* Control characters \b
, \n
, \t
, \f
, \r\
* Unicode