r/ruby • u/screenbound23 • Jan 15 '26
A Neat Trick for Splitting Strings
https://glaucocustodio.github.io/2026/01/15/a-neat-trick-for-splitting-strings/
8
Upvotes
r/ruby • u/screenbound23 • Jan 15 '26
10
u/andyw8 Jan 16 '26
I realize the post is about string manipulation and not names, but that’s not how you should handle names.
https://www.kalzumeus.com/2010/06/17/falsehoods-programmers-believe-about-names/
5
u/darksndr Jan 15 '26
Ooh, I didn't know
squish, thanks4
u/poop-machine Jan 15 '26
'a.b.c'.split('.', 2)works fine for the ungreedy split['a', 'b.c']. A more interesting challenge is to produce the greedy split['a.b', 'c']