只是想学一下BASH_REMATCH。
在ubuntu16.10上,我为BASH_REMATCH写了一个小脚本:
#!/bin/bash
x='sadas123fnrejkwhfklde'
if [[ $x =~ ([0-9]*) ]]
then
echo "match"
echo ${BASH_REMATCH[1]}
else
echo "not match"
fi然而,当/i运行此脚本时,只显示“匹配”,而不显示捕获的匹配!
bash版本为:
$ bash --version
GNU bash, version 4.3.48(1)-release (x86_64-pc-linux-gnu)
Copyright (C) 2013 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software; you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.任何反馈都是值得感谢的。
https://stackoverflow.com/questions/47564834
复制相似问题