在数字上拆分字符串,保留数字

ben*_*ben 8 ruby regex

我有一个字符串,它总是至少是一个数字,但也可以在数字之前和/或之后包含字母:

"4"
"Section 2"
"4 Section"
"Section 5 Aisle"
Run Code Online (Sandbox Code Playgroud)

我需要像这样拆分字符串:

"4" becomes "4"
"Section 2" becomes "Section ","2"
"4 Aisle" becomes "4"," Aisle"
"Section 5 Aisle" becomes "Section ","5"," Aisle"
Run Code Online (Sandbox Code Playgroud)

我怎么能用Ruby 1.9.2做到这一点?

out*_*tis 18

String#split保留结果数组中的分隔符regexp中的任何组.

parts = whole.split(/(\d+)/)
Run Code Online (Sandbox Code Playgroud)