help-bash
[Top][All Lists]
Advanced

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

Re: Not matching string with wildcard in if statement


From: Greg Wooledge
Subject: Re: Not matching string with wildcard in if statement
Date: Mon, 9 Mar 2020 12:41:17 -0400
User-agent: Mutt/1.10.1 (2018-07-13)

On Mon, Mar 09, 2020 at 11:29:45AM -0500, Jesse Hathaway wrote:
> another option is to use a regex test `=~`, see below:

> if [[ "$IOS_SDK" == "iPhoneOS" && "$IOS_CPU" == armv7* ]]; then
>   printf 'Matched arm with glob\n'
> fi
> 
> if [[ "$IOS_SDK" == "iPhoneOS" && "$IOS_CPU" =~ armv7.* ]]; then
>   printf 'Matched arm with regex\n'
> fi

Note that the regex test and the glob test aren't the same.  Glob tests
are implicitly anchored to the start and end of the string being matched.
Regexes are not anchored unless you add ^ and $ yourself.



reply via email to

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