Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9319241
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 19, 20262026-06-19T03:20:07+00:00 2026-06-19T03:20:07+00:00

I want to see if a string contains another string where both strings are

  • 0

I want to see if a string contains another string where both strings are variables. Basically it is that same as this thread but with two variables. Taking that solution and applying it to my situation with !VAR1! and !VAR2! (these variables are declared within the FOR loop) I tried:

if not x!VAR1:!VAR2!=!==x!VAR1! ECHO It contains !VAR2!

Unfortunately it doesn’t work. Any help would be greatly appreciated. I have also declared SETLOCAL EnableDelayedExpansion so I can access the variables.

Any help would be greatly appreciated!

Thanks!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-19T03:20:09+00:00Added an answer on June 19, 2026 at 3:20 am

    As Aacini and rojo have shown, you must use a different expansion for the two variables, normal inside, and delayed outside.

    But perhaps you are running the IF within the same code block that sets the variable. Now you can’t use normal expansion. The solution is to transfer the inner variable to a FOR variable.

    (
      :: Some code that sets the value of var2 
      ::
      for /f "delims=" %%A in ("!var2!") do if "!var1:%%A=!" neq "!var1!" echo It contains %%A
    )
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

So I have two files, one that contains my text, and another which I
I have the exact string : 123.. I want to see what its length
I want to be able to check a string to see if it has
I want see the source code of System.Web.Routing.RouteValueDictionary class. But Reflector can't disassemble it
I want to see class, function and variable/property, dependencies visually, like NDepend , but
strange problem here that I've been pondering. I have a string that contains HTML,
I have a txt variable that contains my html string that I need to
I have a profile page that contains a series of images. I want to
This question follows another, just solved here Now I want to do a different
I want to see if a time I read from a db overlaps with

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.