ES.EXE, Regex & (^) start of string ?

If you are experiencing problems with "Everything", post here for assistance.
Post Reply
therube
Posts: 5711
Joined: Thu Sep 03, 2009 6:48 pm

ES.EXE, Regex & (^) start of string ?

Post by therube »

ES.EXE, regex: & (^) start of string ?

data set:

Code: Select all

/go-red-99 ^ red-09.jpg
/red-01.jpg
/red-02.jpg
Wanted search:
regex:^red-0.\.
(to find red-01.jpg & red-02.jpg).

How to do that with ES?
Tried ^ inside & outside the parenthesis, ^^, ^^^, regex:, -regex,...
Is path playing in?

es -instance 15 pic: -highlight regex:^"red-0.\."

es -instance 15 pic: -highlight -regex ^"red-0.\."


I get all 3 items, but I'm only expecting 2?
void
Developer
Posts: 19839
Joined: Fri Oct 16, 2009 11:31 pm

Re: ES.EXE, Regex & (^) start of string ?

Post by void »

Escape
^
with
^^
or
"^"

Code: Select all

es -instance 15 pic: -highlight regex:^^red-0.\.

Code: Select all

es -instance 15 pic: -highlight regex:"^red-0.\."
therube
Posts: 5711
Joined: Thu Sep 03, 2009 6:48 pm

Re: ES.EXE, Regex & (^) start of string ?

Post by therube »

ok, so it was my BATCH files
which were eating the ^


go.bat, with a search of,
regex:^^red-0.\.
:

Code: Select all

ECHO %*
ECHO "%*"
Results:

regex:red-0.\.
"regex:^red-0.\."

now, the ECHO, with QUOTES, is "OK" - as far as that goes
but when it gets to the actual ES.EXE command-line, i'm wrong, again

ES.BAT, without quotes:
@es.ex2 -instance 15 %*
- gives erroneous results, cause the ^ was stripped

ES.BAT, with quotes:
@es.ex2 -instance 15 "%*"
- gives no results, & if not for that, it might be fine, heh ;-)

i'll have to mess with this again, later...


Batch character escaping
How-to: Escape Characters, Delimiters and Quotes at the Windows command line.
Debugging your batch files

And I suppose I ought to revisit, ES, how to ESCape | passed to a BAT file?.
therube
Posts: 5711
Joined: Thu Sep 03, 2009 6:48 pm

Re: ES.EXE, Regex & (^) start of string ?

Post by therube »

(I guess I wasn't really giving the full story...)

Typically I use batch files...

ah, i had -p in my batch file
& while, in general, i hadn't paid attention to it,
when i did /look/, i took it to mean, Pause - rather then Path

so knowing that...

with -no-p added to my command line, i'm ... working as expected
(just noting, with some searches still need to quaduple the ^, so ^^^^. or quotes...)

(maybe i'll get around to parsing the command line & if <regex:>, automatically add -no-p)

ECHO's help ;-)

Code: Select all

:: SSSq - SSS.bat *with* QUOTES

echo %*
pause


@echo OFF

echo %*
echo "%*"
pause

SET XES=%*
ECHO XES: %XES%
SET XES="%*"
ECHO "XES:" %XES%
pause

echo Found (& NOTE THE -p !!!):
es.ex2  -instance 15  -name -highlight distinct:  audio:  -p %*  
PAUSE

goto end:
Results (nothing):

Code: Select all

C:\out\red>sssq regex:"^thick as a brick"

C:\out\red>echo regex:"^thick as a brick"
regex:"^thick as a brick"

C:\out\red>pause
Press any key to continue . . .
regex:"^thick as a brick"
"regex:"thick as a brick""
Press any key to continue . . .
XES: regex:"^thick as a brick"
"XES:" "regex:"thick as a brick""
Press any key to continue . . .
Found:
Press any key to continue . . .
Results, with -no-p added in - expected:

Code: Select all

C:\out\red>sssq regex:"^thick as a brick" -no-p

C:\out\red>echo regex:"^thick as a brick" -no-p
regex:"^thick as a brick" -no-p

C:\out\red>pause
Press any key to continue . . .
regex:"^thick as a brick" -no-p
"regex:"thick as a brick" -no-p"
Press any key to continue . . .
XES: regex:"^thick as a brick" -no-p
"XES:" "regex:"thick as a brick" -no-p"
Press any key to continue . . .
Found:
Thick As A Brick - Track01 (320).mp3
Thick As A Brick (320).mp3
Press any key to continue . . .
NOTE: that for -no-p, from the command-line, to override the -p in the .bat file,
the -p in the .bat file must come BEFORE the %* (as arguments are generally
evaluated left to right)

search: go.bat regex:"^thick as a brick" -no-p

Code: Select all

es.ex2  -instance 15  -name  -highlight  distinct:  audio:  -p  %*   !I: !H:   -no-result-error
search: go.bat regex:"^thick as a brick" -no-p

Code: Select all

es.ex2  -instance 15  -name  -highlight  distinct:  audio:  %*  -p   !I: !H:   -no-result-error
If you didn't want to add -no-p to your command-line,
you can automate it, checking for regex:, & if found run an ES without the -p

Code: Select all

SET XES=%*
ECHO %XES% | grep -i "regex:"
@if %errorlevel% EQU 0 goto regexfound:


echo Found:
es.ex2  -instance 15  -name -highlight distinct:  audio:  -p  %*   !I: !H: -no-result-error
PAUSE

 goto end:

:regexfound
ECHO regex: was found, skipping path
es.ex2  -instance 15  -name -highlight distinct:  audio:      %*   !I: !H: -no-result-error

 goto end:
(Now, if you don't use -p, I do, then it's immaterial ;-).)
Post Reply