[Top][All Lists]

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

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

From: Linda Walsh
Subject: Re: How to match regex in bash? (any character)
Date: Thu, 17 Nov 2011 16:46:06 -0800
User-agent: Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv: Gecko/20100228 Lightning/0.9 Thunderbird/ Mnenhy/

Chet Ramey wrote:

On 9/27/11 6:41 PM, Roger wrote:

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)?

The bash man page refers to regex(3).  On my BSD (Mac OS X) system, that
refers to re_format(7), which documents the BRE and ERE regular expression
formats.  On an Ubuntu box, to choose a representative Linux example, that
refers to regex(7), which contains the same explanation, and the GNU regex
manual.  This sort of "chained" man page reference is common.

If you like info, `info regex' on a Linux box should display both pages.

        If the poor guy looked at the pages you suggest,
he'd see various examples showing:

An atom is a regular expression enclosed in "()"
A bracket expression is a list of characters enclosed in "[]"
 To  use  a  literal
'-'  as  the first endpoint of a range, enclose it in "[." and ".]"For
example, if o
and ^  are  the  members  of  an  equivalence  class,  then  "[[=o=]]",
"[[=^=]]",  and  "[o^]"  are  all synonymous.ents.  A
null string is considered longer than no match at  all.   For  example,
"bb*"    matches    the    three    middle   characters   of   "abbbc",
"(wee|week)(knights|nights)"  matches  all  ten  characters  of  "week‐
 nights",  when "(.*).*" is matched against "abc" the parenthesized sub‐
expression matches all three characters, and when  "(a*)*"  is  matched
against  "bc"  both  the  whole  RE and the parenthesized subexpression
match the null string.

reply via email to

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