Jump to content

Determine if a string is squeezable: Difference between revisions

Frink
(→‎{{header|Vlang}}: Fixed the emoji problem.)
(Frink)
Line 1,797:
</pre>
 
=={{header|Frink}}==
<lang frink>squeeze[str, ch] := str =~ subst["($ch)\\1+", "$$1", "g"]
 
lines = [["", [""]],
[""""If I were two-faced, would I be wearing this one?" --- Abraham Lincoln """, ["-"]],
["..1111111111111111111111111111111111111111111111111111111111111117777888", ["7"]],
["I never give 'em hell, I just tell the truth, and they think it's hell. ", ["."]],
[" --- Harry S Truman ",[" ", "-", "r"]]]
 
for [line, chars] = lines
for char = chars
println[squeeze[line, char]]</lang>
{{out}}
<pre>
 
"If I were two-faced, would I be wearing this one?" - Abraham Lincoln
..1111111111111111111111111111111111111111111111111111111111111117888
I never give 'em hel, I just tel the truth, and they think it's hel.
--- Harry S Truman
- Harry S Truman
--- Hary S Truman
</pre>
 
=={{header|Go}}==
494

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.