Comparison of programming languages (strings): Difference between revisions

Content deleted Content added
m String literals: Forgot to move a section
String literals: Merge alternate quotes into their respective sections so their semantics are obvious
Line 81:
|-
| <tt>"Hello, $name!"</tt>
| PHPBash shell, Perl, Windows PowerShellPHP, BashWindows shellPowerShell
|-
| <tt>qq(I said "Hello, $name!")</tt>
| Perl (alternate)
|-
| <tt>"Hello, {$name}!"</tt>
| PHP (alternate)
|-
| <tt>"Hello, #{name}!"</tt>
| CoffeeScript, Ruby
| Ruby, CoffeeScript
|-
| <tt>{I said "%Q(Hello, world#{name}!"})</tt>
| Ruby (alternate)
|-
| <tt>(format t "Hello, ~A" name)</tt>
Line 98 ⟶ 104:
| Swift
|}
 
=== Escaped quotes ===
"Escaped" quotes means that a 'flag' symbol is used to warn that the character after the flag is used in the string rather than ending the string.
Line 118 ⟶ 123:
| <tt>"I said ^"Hello, world!^""</tt>
| REBOL
|-
| <tt>q({I said "Hello, world!")}</tt>
| REBOL (alternate)
|-
| <tt>"I said, %"Hello, World!%""</tt>
Line 166 ⟶ 174:
| <tt>R"(Hello, world!)"</tt>
| C++11
|}
 
{{Expand section|date=June 2008}}
 
=== Multiple quoting ===
 
<!-- Before you add your favorite language to this table, make sure it's not listed in another section. -->
{| class="wikitable"
|-
! Syntax
! Language(s)
|-
| <tt>q(I said "Hello, world!")
qq(I said "Hello, $name!")</tt>
| Perl (raw & interpolated)
|-
| <tt>%Q(I said "Hello, world!")
%(I said "Hello, world!")</tt>
| Ruby
|-
| <tt>{I said "Hello, world!"}</tt>
| REBOL
|}