How to split string according to regex in bash script

Viewed 10532

I have such a string:

msg='123abc456def'

Now I need to split msg and get the result as below:

['123', 'abc', '456', 'def']

In python, I can do like this:

pattern = re.compile(r'(\d+)')
res = pattern.split(msg)[1:]

How to get the same result in bash script?
I've tried like this but it doesn't work:

IFS='[0-9]'    # how to define IFS with regex?
echo ${msg[@]}
3 Answers
Related