【发布时间】:2015-12-30 18:43:02
【问题描述】:
我正在学习 bash 编程,特别是正则表达式,我发现了这段代码:
numpat='^[+-]([0-9]+)$'
strpat='^([a-z]*)\1$'
read stringa
if [[ $stringa =~ $numpat ]]
then
echo "numero"
echo numero > output
exit ${BASH_REMATCH[1]}
elif [[ $stringa =~ $strpat ]]
then
echo "echo"
echo echo > output
exit 11
fi
我不明白这一行中的\1 是什么意思:
strpat='^([a-z]*)\1$'
【问题讨论】:
-
你读过正则表达式教程吗?他们应该解释表达的每个元素的含义。