[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: How to use [[ string =~ regexp ]]?
From: |
Paul Jarc |
Subject: |
Re: How to use [[ string =~ regexp ]]? |
Date: |
Sun, 21 May 2006 15:55:35 -0400 |
User-agent: |
Gnus/5.110003 (No Gnus v0.3) Emacs/21.4 (gnu/linux) |
Peter Volkov <pvolkov@mics.msu.su> 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