I am new to ruby and regular expressions and trying to figure out how to attack seperating the attached string of baseball players into first/last name combinations.
This is a sample string:
"JohnnyCuetoJ.J.PutzBrianMcCann"
This is the desired output:
Johnny Cueto
J.J. Putz
Brian McCann
I have figured out how to separate by capital letters which gets me close, but the outlier names like J.J. and McCann mess that pattern up. Anyone have ideas on the best way to approach this?
If you don’t have to do it in one single
gsubthan it gets a bit easier.…and of course you can put this on a single line by chaining the
gsubcalls, but that will basically kill the readability of the code (but on the other hand, how readable is a block of regexen anyway?)