Bash – What regular expression engine type does bash use

bashregular expression

I use RegEx Buddy to prototype and debug my regular expressions. RegEx Buddy allows me to choose between a number of different regular expression engine types (.NET, Java, Perl, GNU BRE, GNU ERE, POSIX, BRE, POSIX ERE etc).

What regular expression engine does bash use (for example in if and case statements)? I'm running Centos 5.5 32 bit and bash 3.2.25(1):

[kevin@mon01 scratch]$ bash --version
GNU bash, version 3.2.25(1)-release (i686-redhat-linux-gnu)
Copyright (C) 2005 Free Software Foundation, Inc.

I'm guessing it'll be GNU BRE or GNU ERE?

Best Answer

bash (and POSIX shells in general) do not use regular expressions in the case statement, rather glob patterns.

There's limited support for regular expressions using the =~ operator; see details at: http://mywiki.wooledge.org/BashGuide/Patterns,
which says that bash uses Extended Regular Expressions (ERE).

Related Question