Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.

Author Topic: Wildcards in 'equal to' statement  (Read 2526 times)

0 Members and 1 Guest are viewing this topic.

gregory

    Topic Starter


    Beginner

    Thanked: 1
    • Experience: Experienced
    • OS: Linux variant
    Wildcards in 'equal to' statement
    « 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.

    Dias de verano

    • Guest
    Re: Wildcards in 'equal to' statement
    « Reply #1 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

    « Last Edit: February 27, 2009, 05:57:29 AM by Dias de verano »

    gregory

      Topic Starter


      Beginner

      Thanked: 1
      • Experience: Experienced
      • OS: Linux variant
      Re: Wildcards in 'equal to' statement
      « Reply #2 on: February 27, 2009, 05:18:05 AM »
      Surely, I should have thought of that. Thank You. ;)