# shell 数字不支持/d ,只能使用[0-9]
if [[ "abcyyy13554221547HelloxxxWorld" =~ yyy([0-9]{11})(Hello)xxx(.*) ]]
then
echo The regex matches!
echo $BASH_REMATCH
echo ${BASH_REMATCH[1]}
echo ${BASH_REMATCH[2]}
echo ${BASH_REMATCH[3]}
fi
The regex matches!
yyy13554221547HelloxxxWorld
13554221547
Hello
World
原创文章,作者:ItWorker,如若转载,请注明出处:https://blog.ytso.com/280821.html