Regular expressions (Bash): verschil tussen versies
Naar navigatie springen
Naar zoeken springen
(Nieuwe pagina aangemaakt met 'Om regex te gebruiken in vergelijkingen, gebruik <code>=~</code>. Zie https://www.networkworld.com/article/2693361/operating-systems/unix-tip-using-bash-s-regular-e...') |
|||
Regel 1: | Regel 1: | ||
− | + | To use regular expressions in Bash comparisons, use operator <code>=~</code>, like | |
+ | |||
+ | <pre> | ||
+ | if [[ "$switches" =~ [f] ]]; then | ||
+ | echo "f - Create folder structure" | ||
+ | mappenstructuur=true | ||
+ | fi | ||
+ | </pre> | ||
+ | |||
+ | I have the impression that regular expressions (regex) in Bash may not be the same as in MySQL, hence some more details in this article. | ||
+ | |||
+ | == See also == | ||
+ | |||
+ | * [[Bash - String comparison | String comparison (Bash)]] | ||
+ | * [[Regex (MySQL)]] | ||
+ | |||
+ | == Sources == | ||
+ | |||
+ | * https://www.networkworld.com/article/2693361/operating-systems/unix-tip-using-bash-s-regular-expressions.html |
Versie van 29 sep 2022 12:45
To use regular expressions in Bash comparisons, use operator =~
, like
if [[ "$switches" =~ [f] ]]; then echo "f - Create folder structure" mappenstructuur=true fi
I have the impression that regular expressions (regex) in Bash may not be the same as in MySQL, hence some more details in this article.