Hi,
I’m using ruby 1.8.5
i have an input string whose ‘words’ are separated by whitespace and/or
commas and/or semicolons
I want to remove the separators (,;\s) and place each ‘word’ into an
array
e.g.,
this string => 'my uncle, jumped over;
the moon’
would be converted into an array of elements [‘my’, ‘uncle’, ‘jumped’,
‘over’, ‘the’, ‘moon’]
currently, i’m doing this (in this example, rx_input holds the string
and rx_numbers is the array):
rx_input.gsub!(/[,;\s]/, ' ')
rx_input.squeeze!(' ')
rx_numbers = rx_input.split(' ')
is there a simpler /more elegant/ way of doing this (accounting for the
possibility of double-spaces, etc)?
tia