regex - [[ $string = *[!0-9]* ]] 在 bash 中是什么意思?

标签 regex linux bash

我正在学习 bash,特别是正则表达式,我在我的书中找到了这个:

read strin

if [[ $strin = *[!0-9]* ]]; then

   echo "error"

else
   echo "success"

fi

我的问题是我不明白这个正则表达式的意思,尤其是我不明白 '!'在范围中。

最佳答案

这是一个模式匹配的例子。如果 string 的值由 0 个或多个字符组成,后面跟着一个在 0-9 范围内的字符(即非数字字符),则它会成功), 后跟零个或多个任意字符。简而言之,该模式匹配任何包含至少一个非数字字符的内容。

关于regex - [[ $string = *[!0-9]* ]] 在 bash 中是什么意思?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30874810/

相关文章:

linux - 新的命令行工具 : unique name

php - 用于 PHP 的正则表达式看起来很简单但是让我很痛苦

c - 术语.h : header not found

java - 异常在线程 "IDL"java.lang.UnsatisfiedLinkError : no idl_ips in java. library.path

python - 有没有一种方法可以安排 docker 容器相互运行?

bash - float 列表的平均值 Bash

regex - 用 Perl 标记逗号

regex - 如何在oracle(pl/sql)中转义字符串中的特殊字符

Python 比较列表中的部分字符串

linux - -bash : $: command not found when installing Dart package