Determine if a string is squeezable: Difference between revisions

Fixed Frink
(Frink)
(Fixed Frink)
Line 1,798:
 
=={{header|Frink}}==
<lang frink>squeeze[str, ch] := str =~ subst["($ch)\\1+", "$$1", "g"]
{
println["Use: '$ch'"]
println["old: " + length[str] + " <<<$str>>>"]
str =~ subst["($ch)\\1+", "$$1", "g"]
println["new: " + length[str] + " <<<$str>>>"]
}
 
lines = [["", [""]],
Line 1,811 ⟶ 1,817:
{{out}}
<pre>
Use: ''
old: 0 <<<>>>
new: 0 <<<>>>
 
Use: '-'
old: 72 <<<"If I were two-faced, would I be wearing this one?" --- Abraham Lincoln >>>
new: 70 <<<"If I were two-faced, would I be wearing this one?" - Abraham Lincoln >>>
 
Use: '7'
old: 72 <<<..1111111111111111111111111111111111111111111111111111111111111117777888>>>
new: 69 <<<..1111111111111111111111111111111111111111111111111111111111111117888>>>
 
Use: '.'
old: 72 <<<I never give 'em helhell, I just teltell the truth, and they think it's helhell. >>>
new: 69 <<<I never give 'em hel, I just tel the truth, and they think it's hel. >>>
 
Use: ' '
old: 72 <<< --- Harry S Truman >>>
new: 20 <<< --- Harry S Truman >>>
 
Use: '-'
old: 72 <<< --- HaryHarry S Truman >>>
new: 70 <<< - Harry S Truman >>>
 
Use: 'r'
old: 72 <<< --- Harry S Truman >>>
new: 71 <<< --- Hary S Truman >>>
 
"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>
 
494

edits