Tuesday, 20 August 2013

Ruby: Using split and regex

Ruby: Using split and regex

I am trying to take in a line of text as follows:
1 | Company 1234 Anywhere St, SJ (12.34567, -98.765432)
and isolate the first number and the two floats.
I have been playing with a RegEx creator and came up with the following:
To get the first integer: (\\d+) To get the floats:
([+-]?\\d*\\.\\d+)(?![-+0-9\\.])
But when I use these with .split I am getting "syntax error, unexpected
$undefined, expecting ')'"
Any insight would be great!

No comments:

Post a Comment