I am currently looking for the fastest way to parse a string in Ruby. The string has the format:
"#{String1}>#{String2}(#{Integer})", for example "Hello>World(25)"
and I am looking to retrieve the values of String1, String2, and Integer out of it. My current way of doing it is just
s1 = "Hello"
s2 = "World"
i = 25
str = "#{s1}>#{s2}(#{i})"
str = str.split('>')
newStr = str[1].split('(')
str[1] = newStr[0]
str[2] = newStr[1].chomp(')').to_i
print(str) # => ["Hello", "World", 25]`
I am looking for any way faster than this to speed up my program. Thanks.