Solved How to scan a variable in batch?

November 14, 2011 at 18:16:24
Specs: Windows 7
I have the user type a variable and if the variable contains http:// to goto remove and then in remove it removes the http:// and does other stuff.

I am NOT looking for a single line of code that finds and removes it I NEED a line (or multiple) that scans it then a SEPARATE one that removes it.

(I'm doing this because after that it does this:
OPEN http://%web%
and it would cause errors if you typed something like this:

See More: How to scan a variable in batch?

Report •

November 15, 2011 at 06:45:30
Not sure if you need the following

set web=%web:http://=%

The above statement removes http:// from the string assigned to the variable.

Report •

November 15, 2011 at 17:28:22
@IVO That will be helpful but I need something to search the string the come back true or false for whether or not it's in there

Report •

November 15, 2011 at 23:59:35
✔ Best Answer
You could always compare the modified string to the original:

if "%web:http://=%"=="%web%" (
    echo the string doesn't contain http://
) else (
    echo the string contains http://

Report •

Related Solutions

November 16, 2011 at 20:56:48
@Judago that's a great idea!! I can use this:

if "%web:http://=%"=="%web%" (
set con=false
) else (
set con=true

Report •

Ask Question