Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 3 months ago.
Improve this question
I would like to check the string is match or not. I tried this way, but it always return error, syntax error, I don't know which syntax that error.
Error message
The syntax of the command is incorrect.
if TXT EQU TXT(
SET Format=TXT
REM ECHO %Format%
if %Format% EQU TXT(
ECHO Format correct
GOTO END
)
ECHO Format not correct
This works for me:
#echo off
set format=TXT
if "%format%"=="TXT" (
#echo Format correct
goto :end
)
#echo Format not correct
:end
Related
Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed yesterday.
Improve this question
I am writing a batch script, and I need to use nested IF NOT in order to mimic 'AND AND' logic.
When trying to run it, I get an error:
"!ext!" was unexpected at this time.
I am not pasting the whole script since the issue is clearly in the nested IF NOT piece. (It works if I remove that). Here is the relevant part:
if not exist "%dst%!relPath!" (
echo file "%dst%!relPath!" does NOT EXIST and it will be created
rem Check if the file extension is png jpg or mp4
if /I "!ext!" == ".png" (
echo It worked!!
)
if /I "!ext!" == ".jpg" (
echo It worked2!!
)
if /I "!ext!" == ".mp4" (
echo It worked3!!
)
if not /I "!ext!" == ".png" if not /I "!ext!" == ".jpg" if not /I "!ext!" == ".mp4" (
echo It worked4!!
)
)
The first 3 ifs are okay, but the 4th if statement, the nested one, is giving me that error, and I can´t see where the issue could be, (unless IF NOT is not supported as nested.
Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 7 months ago.
Improve this question
I'm trying to create a string that will verify if input time is in the right format. I keep getting the 'else' portion to execute, but never the 'then' portion. I'm not sure where in the string there is a mistake. I execute the script in the shell using ./. I test it with 01:20. It will give me "Time entered is valid." when I input single digit int values. I want it to recognize the 00:00 format. Any suggestions?
echo "enter time" ; read time
if [[ '^(([01][0-3])|([2][0-9]))[:][0-5][0-9]$' =~ $time ]]
then
echo "Time entered is valid."
else
echo "Time entered is NOT correct."
fi
=~ is not commutative; the string you want to match must go on the left, the regular expression on the right.
if [[ $time =~ '^(([01][0-3])|([2][0-9]))[:][0-5][0-9]$' ]]
Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 3 years ago.
Improve this question
I am trying to delete "PK WND 16026/1736" from the below text by removing any text between "RMK A02" and "SLP."
Text
KDFW 151753Z 17018G25KT 10SM FEW035 FEW120 SCT250 32/21 A2983 RMK AO2 PK WND 16026/1736 SLP093 T03220211 10322 20239 58008
Code
sed -e 's/\(RMK A02\).*\(SLP\)/\1\2/'
The above code doesn't appear to be working/deleting "PK WND 16026/1736."
Here is one way to do it:
awk -F"RMK AO2.*SLP" '{$0=$0~FS?$1"RMK AO2 SLP "$2:$0}1' file
KDFW 151753Z 17018G25KT 10SM FEW035 FEW120 SCT250 32/21 A2983 RMK AO2 SLP 093 T03220211 10322 20239 58008
Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 3 years ago.
Improve this question
Using Python 3.4.3
I'm trying to do a regex to split CSS like identifiers. My pattern is:
pattern = re.compile("(?P<tag>[^.#]+)?(#(?P<iḍ>[^.#]+))?(?P<classes>([.][^.#]+)+)?")
My test string is h2#label. When I do the match, the groups I get are ('h2', '#label', 'label', None, None) which is correct.
If I get the groupdict of the match I get {'classes': None, 'iḍ': 'label', 'tag': 'h2'} which also looks correct. However, when I try to retrieve the value of id I get a result as if it's not present.
Doing "id" in match.groupdict() yields False and doing "match.groupdict().get("id")yieldsNone`.
Any idea what's wrong here and how to solve it?
You need to fix the typo: instead of 'iḍ' type 'id'.
pattern = re.compile("(?P<tag>[^.#]+)?(#(?P<id>[^.#]+))?(?P<classes>([.][^.#]+)+)?")
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Closed 5 years ago.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Improve this question
I'm trying to remove all the non-alphabetic characters in a string in a VBScript that will run from the command line.
Here's what I have thus far:
Set wshShell = CreateObject("WScript.Shell")
Dim test
test = "Hello:, world!"
test = strClean(test)
WScript.Echo(test)
Function strClean(strVal)
Set objRegEx = CreateObject(“VBScript.RegExp”)
objRegEx.Global = True
objRegEx.Pattern = “[^A-Za-z\n\r]”
strSearchString = objRegEx.Replace(strVal, “”)
End Function
But I'm getting the following error:
my.vbs (8, 35) Microsoft VBScript compilation error: Invalid character
The quotes you're using are Unicode and are invalid.
You should replace them by ASCII ones.
This is a community answer from Slai's comment that doesn't want to write an answer.See this meta post for more info.