Comparison of programming languages (string functions): Difference between revisions

Content deleted Content added
left: lang="vb"
m Format: lang="c"
Line 1,323:
"My %s costs $%.2f" % ("pen", 19.99); # returns "My pen costs $19.99"
"My {0} costs ${1:.2f}".format("pen", 19.99); # returns "My pen costs $19.99"
</syntaxhighlight>
<syntaxhighlight lang="python3">
#Example in Python 3.6+
pen = "pen"
f"My {pen} costs {19.99}" #returns "My pen costs 19.99"
</syntaxhighlight>

<syntaxhighlight lang="scheme">
; Example in Scheme
(format "My ~a costs $~1,2F" "pen" 19.99) ; returns "My pen costs $19.99"
</syntaxhighlight>
 
<syntaxhighlight lang="c">
<pre>
/* example in PL/I */
put string(some_string) edit('My ', 'pen', ' costs', 19.99)(a,a,a,p'$$$V.99')
/* returns "My pen costs $19.99" */
</syntaxhighlight>
</pre>
<!-- endsection -->