Assuming the quirky rules from http://www.dostips.com/forum/viewtopic.php?f=3&t=3803 are not in my batch file (Only whitespaces are present), how can I detect batch labels using FINDSTR?
For instance, (Sample.bat)
Code: Select all
::Intro comments
::Blablabla
::Yeah!!!
::Blablabla
@echo off
::Comment again
goto :main
::Some codes here...
:main
::Some code here
echo This is some piece of code...
:thisisalabel
::this is a comment...
pause
exit /b
From my young intuition, I tried to use this FINDSTR command:
Code: Select all
>findstr /r ":[^:][^:]*" Sample.bat
I expect that only :main and :thisisalabel will appear, but the output became:
Code: Select all
::Some comments
::Blablabla
::Yeah
::Blablabla
::Comment again
goto :main
::Some codes here...
:main
::Some code here
:thisisalabel
::this is a comment...
What is wrong with my FINDSTR? Thanks a lot guys!
Meerkat