Link to home
Create AccountLog in
Avatar of knightEknight
knightEknightFlag for United States of America

asked on

replace = in a batch string

I'm looking for a quick way to do a string substitution of the '=' symbol.

In batch strings you can do simple search/replace like this:

  set myvar=this=that
  echo  %myvar% - %myvar:t=T%

  result:  this=that - This=ThaT

But I'm looking for a simple way to replace the '=' symbol WITHOUT having to loop thru the string and re-build it.
Here's what I've tried:

  echo %myvar:==X%
  echo %myvar:^==X%

  desired result:  thisXthat

Any non-looping ideas?  (or sourced confirmation that it can't be done?)


ASKER CERTIFIED SOLUTION
Avatar of Bill Prew
Bill Prew

Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
See answer
Avatar of knightEknight

ASKER

Thanks Bill.  Actually I've already worked similar solutions before I posted.  The problem with the first is that I would first have to substitute all the equals with pounds in all the variables, which is the problem I'm trying to resolve.  As for the second solution, that is exactly what I'm doing now.  It works well enough, but it's just messy.
SOLUTION
Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
yes, that is actually similar to what I'm doing now.

Thanks guys - it is good enough for me to know that the real answer is that there isn't one!  :)