help-bash
[Top][All Lists]
Advanced

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

Re: [Help-bash] ${#BASH_REMATCH[*]}


From: Greg Wooledge
Subject: Re: [Help-bash] ${#BASH_REMATCH[*]}
Date: Tue, 7 Feb 2012 12:49:09 -0500
User-agent: Mutt/1.4.2.3i

On Wed, Feb 08, 2012 at 12:44:34AM +0800, J. M. wrote:
>     if [[ $1 =~ $regex ]]; then
>         echo "$1 matches"
>         i=1
>         n=${#BASH_REMATCH[*]}  ##### dose someone know what's going on
> with this part? I am totally confused.

BASH_REMATCH is an array which is populated by the =~ operator earlier.
You can read about it in the manual.

${#arrayname[*]} is an expression which evaluates to the number of elements
in the array.  So the line in question is counting how many elements are
in BASH_REMATCH and then storing that in the variable n.



reply via email to

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