I have a sequence of strings which may or may not contain a delimiter
val words = Seq("1 $ cake", "2biscuit", "3brownie", "4 $ honey")
I would need to create a resulting sequence from above - if '$' exists , take the preceding bit after trimming, else the whole string.
val res = Seq("1", "2biscuit", "3brownie", "4")
I am looking for a safe and efficient solution to do this in a single pass.
map?