I have a variable defined as such:
Code: Select all
SET "CLOUD_URL=https://planning-z552xxx1.pbcs.us2.oraclecloud.com"
Code: Select all
SET "CLOUD_URL=https://planning-test-z552xxx1.pbcs.us2.oraclecloud.com"
Thank you!
Moderator: DosItHelp
Code: Select all
SET "CLOUD_URL=https://planning-z552xxx1.pbcs.us2.oraclecloud.com"
Code: Select all
SET "CLOUD_URL=https://planning-test-z552xxx1.pbcs.us2.oraclecloud.com"
Code: Select all
SET "CLOUD_URL=https://planning-z552xxx1.pbcs.us2.oraclecloud.com"
SET "SEARCH=test"
ECHO "%CLOUD_URL%" | FINDSTR /C:"%SEARCH%" >nul 2>&1 && ( SET "FLAG=T" )
IF DEFINED FLAG FOR /F "tokens=1,3 delims=-" %%A IN ("%CLOUD_URL%") DO SET "CLOUD_URL=%%~A-%%~B"
IF NOT DEFINED FLAG FOR /F "tokens=1-2 delims=-" %%A IN ("%CLOUD_URL%") DO SET "CLOUD_URL=%%~A-test-%%~B"
Code: Select all
@echo off
SET "CLOUD_URL=https://planning-z552xxx1.pbcs.us2.oraclecloud.com"
if "%CLOUD_URL:-test=%" equ "%CLOUD_URL%" (
set "CLOUD_URL=%CLOUD_URL:planning=planning-test%"
) else (
set "CLOUD_URL=%CLOUD_URL:-test=%"
)
echo %CLOUD_URL%