Question

01: SETLOCAL EnableExtensions EnableDelayedExpansion
02: ... 
03:  IF /i "%tValueType%" EQU "string" (
04:   SET "vValueBefore=%1"
05:   SET "vValueAfter=%2"
06: 
07:   FOR %%p IN (equ neq sub) DO (
08:    IF /i "!tOperator!" EQU "%%p" (
09:     SET "tOperatorValid=valid"
10:     IF /i "!tOperator!" EQU "sub" (
11:      SET "tConditions="!vValueAfter:!vValueBefore!=!" NEQ "!vValueAfter!""
12:     ) ELSE (
13:      SET "tConditions="!vValueBefore!" %tOperator% "!vValueAfter!""
14:     )
15:    )
16:   )
17:  )
18: ...

Line 11: I want replace substring to "" (cut substring) in string but error.

Was it helpful?

Solution 2

11:      for /F "delims=" %%v in ("!vValueBefore!") do SET "tConditions="!vValueAfter:%%~v=!" NEQ "!vValueAfter!""

OTHER TIPS

  SET "tConditions="!vValueAfter:%vValueBefore%=!" NEQ "!vValueAfter!""

should work, since vValueBefore is not being changed in the loop

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top