> On Mon, Sep 26, 2011 at 09:37:07PM -0500, Dennis Williamson wrote:
>On Mon, Sep 26, 2011 at 8:19 PM, Peng Yu <pengyu...@gmail.com> wrote:
>> Hi,
>>
>> I know that I should use =~ to match regex (bash version 4).
>>
>> However, the man page is not very clear. I don't find how to match
>> (matching any single character). For example, the following regex
>> doesn't match xxxxtxt. Does anybody know how to match any character
>> (should be '.' in perl) in bash.
>>
>> [[ "$1" =~ "xxx.txt" ]]
>>
>
>When you quote the string on the right hand side of =~ it changes to a
>simple string match instead of a regex match. It is sometimes
>difficult to specify a regex literally (and unquoted), so it's best to
>use a variable as shown in Steven's reply to you.
>

I believe the Bash Manual also strongly suggests, using variables for matching
as well. ;-)

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

Reply via email to