我有一个简单的字符串,它是一个cql语句:
CREATE KEYSPACE IF NOT EXISTS mykeyspace WITH REPLICATION = {'class': 'SimpleStrategy', 'replication_factor': 1 };
我想从中提取键空间名称(在本例中为mykeyspace
)。我试着做以下事情:
if [[ $cqlstatement =~ ".+EXISTS (.+) WITH.+" ]]; then
keyspace=${BASH_REMATCH[1]}
else
echo "unable to parse cql string $cqlstatement"
exit 1
fi
但我得错误说:
unable to parse cql string CREATE KEYSPACE IF NOT EXISTS mykeyspace WITH REPLICATION = {'class': 'SimpleStrategy', 'replication_factor': 1 };
知道为什么吗?