Computer Hope

Microsoft => Microsoft DOS => Topic started by: gregory on February 27, 2009, 03:39:59 AM

Title: Wildcards in 'equal to' statement
Post by: gregory on February 27, 2009, 03:39:59 AM
For example:

Code: [Select]
set var=value7

if "%var%"=="value*" (echo yes) else (echo no)

This will produce a 'no', seems the == is taken absolutely with no support for wildcards. Any ideas how to make this process work?

Thanks.
Title: Re: Wildcards in 'equal to' statement
Post by: Dias de verano on February 27, 2009, 04:52:07 AM
do a string slice: i.e. check if the first 5 chars of the variable are equal to "value"

if "%variable:~0,5%"=="value" whatever

Title: Re: Wildcards in 'equal to' statement
Post by: gregory on February 27, 2009, 05:18:05 AM
Surely, I should have thought of that. Thank You. ;)