I want to split the string "hello+world-apple+francisco-rome"
, into ["hello", "+world", "-apple", "+francisco", "-rome"]
.
String::split
actually loses the splitting element. Anyone can do that?
I want to split the string "hello+world-apple+francisco-rome"
, into ["hello", "+world", "-apple", "+francisco", "-rome"]
.
String::split
actually loses the splitting element. Anyone can do that?
You can do it with this simple regular expression:
"hello+world-apple+francisco-rome".scan(/[+\-]?\w+/)