I am writig an app where the user will enter a string and then I need to
split that string into two parts and then I can process the two parts
from there and show them some output.

I need help with the best Ruby way to split the string into the two
parts...

Here are examples of some typical user inputs, and then what it must be
split into for further processing.  Hopefully you will see a pattern to
it and can help me. (Note: sometimes there will be a space between the
two parts, but some user may omit the space between [part 1] and [part
2], so I must handle both cases)

(They will not enter the quotes, I just did it for clarity)

Examples (several to help you see the pattern):

 "80e6"  must split to "80" and "e6"

 "80 e6" must split to "80" and "e6"

 "12.5H7" must split to "12.5" and "H7

 "120 JS11" must split to "120" and "JS11"

 "20.8a11" must split to "20.8" and "a11"

 "45.50 h2" must split to "45.50" and "h2"

 "90.2F3" must split to "90.2" and "F3"

 "45js4" must split to "45" and "js4"


Here is the basic pattern, in words:

[part 1] followed by [part 2]

which is to say:

[part 1 = an integer or floating point number] followed by [part 2 = a
single or double set of letters (a-z or A-Z), which is then folled by an
integer]

If there is a space between [part 1] and [part 2], it needs to be
ignored.


If you are really interested in what all this is for, you can read on...
(it may help you see the overall picture.

Eventually, [part 1] will be converted to a floating point number, and
[part 2] will be used to look up some other floating point number in a
database table which is then used as a variance amount that will be
applied to [part 1].

-- 
Posted via http://www.ruby-forum.com/.