Comma quibbling: Difference between revisions

Add ed example
m (→‎{{header|PHP}}: fix formatting.)
(Add ed example)
 
Line 1,613:
("ABC" "DEF" "G" "H") ----> "{ ABC, DEF, G and H }"
</syntaxhighlight>
 
=={{header|ed}}==
 
Uses basic regular expressions (BREs).
 
<syntaxhighlight lang="sed">
# by Artyom Bologov
H
,p
g/.*/s/ /, /g
g/[,]/s/,\([^,]*\)$/ and\1/
g/.*/s//{&}/
,p
Q
</syntaxhighlight>
 
{{out}}
 
<pre>$ ed -s comma-quibling.input < comma-quibling.ed
Newline appended
 
ABC
ABC DEF
ABC DEF G H
{}
{ABC}
{ABC and DEF}
{ABC, DEF, G and H}</pre>
 
=={{header|Eiffel}}==
100

edits