bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How to match regex in bash? (any character)


From: Roger
Subject: Re: How to match regex in bash? (any character)
Date: Tue, 27 Sep 2011 14:41:51 -0800
User-agent: Mutt/1.5.21 (2010-09-15)

> On Tue, Sep 27, 2011 at 08:15:09AM -0400, Greg Wooledge wrote:
>On Mon, Sep 26, 2011 at 07:06:30PM -0800, Roger wrote:
>> Some good reading I found is under the Bash Manual Page section "Parameter
>> Expansion".
>> 
>> From here, to learn more about regex/regexpr as the Bash Manual is quite 
>> brief
>> on regex, use the following manual pages:
>> 
>> perlretut - Gives a good from the start explanation of regular expressions,
>> including perl
>
>Perl's regular expressions are not the same as Bash's.  Bash uses standard
>POSIX Extended Regular Expressions (ERE).  You can find formal documentation
>at 
>http://www.opengroup.org/onlinepubs/009695399/basedefs/xbd_chap09.html#tag_09_04
>
>Or see "man egrep", as egrep (or grep -E) also uses EREs.  Or see any
>web page that discusses EREs.
>
>Avoid reading documentation from a different language (in this case Perl),
>because the features tend to change.  Perl uses a feature set and syntax
>that have been retroactively dubbed Perl Compatible Regular Expressions
>(PCRE).  They're superficially similar to EREs, but have a much broader
>range of features (extensions) that are not compatible and will not work
>in Bash.

Correct.  After reading the entire Bash Manual page, I didn't see much mention
of documentation resources (of ERE) besides maybe something about egrep from
Bash's Manual Page or elsewhere on the web.  After extensive research for
regex/regexpr, only found Perl Manual Pages.

Might be worth mentioning a link or good reference for this ERE within the Bash
Manual (Page)?

-- 
Roger
http://rogerx.freeshell.org/



reply via email to

[Prev in Thread] Current Thread [Next in Thread]