Wednesday, June 24, 2015

Eliminate spaces, -, +, *, /, = and parentheses in a string

Run:

str = "Revenue - Costs * (1 + Profitpercentage)"
p str.scan(/[A-Za-z]+/)

at http://rubyplus.biz/

You will see:

["Revenue", "Costs", "Profitpercentage"]