bug-bash
[Top][All Lists]
Advanced

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

Re: How to use [[ string =~ regexp ]]?


From: Chet Ramey
Subject: Re: How to use [[ string =~ regexp ]]?
Date: Sun, 21 May 2006 16:24:52 -0400
User-agent: Thunderbird 1.5.0.2 (Macintosh/20060308)

Paul Jarc wrote:
> Peter Volkov <address@hidden> wrote:
>> $ [[ "string" =~ "[a-z]" ]] && echo something
>> something
> 
> [a-z] matches only one charater, but the pattern is not required to
> match against the entire string.  You can force it to match the whole
> string by using "^" to anchor the pattern to the beginning of the
> string, and "$" to anchor it to the end:
> [[ string =~ ^[a-z]$ ]]

Paul is correct; that is the piece I was missing (I am distracted by
the Cleveland-Detroit game).

Chet

-- 
``The lyf so short, the craft so long to lerne.'' - Chaucer
                       Live Strong.  No day but today.
Chet Ramey, ITS, CWRU    address@hidden    http://cnswww.cns.cwru.edu/~chet/




reply via email to

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