I'm using Ruby 2.4. I'm having trouble splitting on a regular expression and getting the results into an array. If I have a string like
"A other stuff"
I want to split the first character from teh rest of the string, only if the first character is an "A" or a "B" and there is a space after it. So by those rules, splitting the above would result in
["A", "other stuff"]
but applying those rules to
would result in
(because there is no space after the "A"). I tried
2.4.0 :007 > str = "A more" => "A more" 2.4.0 :009 > str.split(/^([ab])[[:space:]]+/i) => ["", "A", "more"]
but there is this annoying blank character at the beginning of my array, whcih I dont' want there. Thanks for the advice.