Reputation: 3568
I would like to isolate a number within a string by splitting it on two zero-width assertions. I can split on the first
strsplit("nursereviewday36_arm_1", "(?<=[[:alpha:]])(?=[[:digit:]])", perl = T)
So that it returns
[[1]]
[1] "nursereviewday" "36_arm_1"
But I would like to split into three like so
[[1]]
[1] "nursereviewday" "36" "_arm_1"
This is in R but any regex that solves this will do
Upvotes: 0
Views: 45
Reputation: 11356
Try this:
(?<=[[:alpha:]])(?=[[:digit:]])|(?<=[[:digit:]])(?=_)
Upvotes: 2