Bash =~: Difference between revisions

From NovaOrdis Knowledge Base
Jump to navigation Jump to search
Line 1: Line 1:
=Internal=
=Internal=
* [[Bash_Concepts#.3D.7E|bash Concepts]]
* [[Bash_Concepts#.3D.7E|bash Concepts]]
=Overview=
The string to the right of the = ̃ operator is considered an extended regular expression and matched against the string to the left of the operator. The rules governing the extended regular expression are described in regex(3).
<syntaxhighlight lang='bash'>
if [["string_to_be_matched_against_regex" =~ regex ]]; then
  # match
else
  # no match
fi
</syntaxhighlight>
Usage is subject to the following constraints:
*

Revision as of 20:30, 20 September 2019

Internal

Overview

The string to the right of the = ̃ operator is considered an extended regular expression and matched against the string to the left of the operator. The rules governing the extended regular expression are described in regex(3).

if [["string_to_be_matched_against_regex" =~ regex ]]; then
  # match 
else
  # no match 
fi

Usage is subject to the following constraints: