bug-bash
[Top][All Lists]
Advanced

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

Re: Cross-version regular expression...


From: Greg Wooledge
Subject: Re: Cross-version regular expression...
Date: Wed, 13 Apr 2011 15:28:39 -0400
User-agent: Mutt/1.4.2.3i

On Wed, Apr 13, 2011 at 11:19:22AM -0700, Ray Van Dolson wrote:
> I'm trying to get regular expression matching working on both bash v3
> as well as v4.

Put the RE in a variable.

> The following works on v4 (under RHEL6), but not under bash 3.00.15
> (under RHEL4):
> 
> [[ "6Server" =~ ([0-9]+)(.*) ]]

Put the RE in a variable.

> This works on 3.00.15, but not under RHEL6's bash (4.1.2):
> 
> [[ "6Server" =~ '([0-9]+)(.*)' ]]

Put the RE in a variable.  Don't quote the right hand side.  If you quote
the right hand side, it becomes == matching instead of =~ matching.

re='([0-9]+)(.*)'
[[ 6Server =~ $re ]]



reply via email to

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