arrays - How to split string without defined delimeter -


i have string looks this:

bar = "bar 01/12/15" foo = "foo02/15/87" 

how can split variables resulting array contains:

bar_array = ["bar", "01/12/15"] foo_array = ["foo","02/15/87"] 

r = /(?<=[[:alpha:]]) ?(?=\d)/  "bar 01/12/15".split(r)   #=> ["bar", "01/12/15"] "foo02/15/87".split(r)   #=> ["foo", "02/15/87"] 

the regular expression reads

  • match letter in positive lookbehind
  • match 0 or 1 spaces
  • match digit in positive lookahead

Comments

Popular posts from this blog

php - Vagrant up error - Uncaught Reflection Exception: Class DOMDocument does not exist -

vue.js - Create hooks for automated testing -

Add new key value to json node in java -