Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!

How to? Search for Text Containing '[' with FSEARCH

Jun
1,092
48
I wanted to use FSEARCH to find all files that contained the function UNQUOTE but not UNQUOTES, so I used the option

/t"@unquote["​

That failed because '[' was interpreted as the start of a character class. I tried escaping it as [ or ^[, but that did not help. I was forced to use a regular expression search instead. It seems to me that there should be some way to override the character class interpretation.

It's also worth noting that I got the error messages, such as TCC: premature end of char-class "(?i)@unquote`[`" , not just once but once for each matching file. And where did the (?i) come from?
 
All searches in FSEARCH are regular expressions. If you don't select the "Regular Expressions" option, FSEARCH will convert the search string to a regex.

If you want to match a literal [, you need to escape it with a backslash (\[).

The (?i) is the regular expression way of saying "ignore case".
 
All searches in FSEARCH are regular expressions. If you don't select the "Regular Expressions" option, FSEARCH will convert the search string to a regex.

It would be helpful if that fact were included in the help information. So the /T option is for people who do not know regular expressions and want the program to convert their (mostly) plain text into one?

If you want to match a literal [, you need to escape it with a backslash (\[).

That doesn't work. I had tried it, though I did not say so in the original posting.

->fsearch /b /t"@unquote\[" a*.btm​
TCC: premature end of char-class "(?i)@unquote\\["​
It does work with the /E switch, but not with /T.
 
Looks like the regular expression engine wants to treat the open bracket as the start of a class. Maybe let it?
Code:
fsearch /b /t"@unquote[[]" a*.btm
 
After going back and actually reading the help file....
Code:
fsearch /b /e"@unquote\[" a*.btm
 
I tried that.

Code:
v:\> fsearch /b /t"@unquote\[" *.btm

It didn't choke and it didn't find anything. But ...

Code:
v:\> fsearch /b /t"@unquote\[" *.btm

v:\> grep unquote *.btm
apppaths.btm:set exe=%@unquotes[%$]
closetcmd.btm:set ntabs=%@unquote[%@tcipc[TCTABS;;2]]
closetcmd.btm:set hwnd=%@unquote[%@tcipc[HWND;;2]]
gettcmdver.btm:set hwnd=%@unquote[%@tcipc[HWND;;2]]
tcplacement.btm:set tcHwnd=%@unquote[%@TCIPC[HWND;;2]]

I also tried @Charles Dye's suggestion. It didn't find anything.

Code:
v:\> fsearch /b /t"@unquote[[]" *.btm

v:\>

And /e didn't help.

Code:
v:\> fsearch /b /e"@unquote\[" v:\*.btm

v:\> fsearch /b /e"@unquote[[]" v:\*.btm

v:\>

Even without the brackets it finds nothing.

Code:
v:\> fsearch /b /e"unquote" v:\*.btm

v:\> fsearch /b /t"unquote" v:\*.btm

v:\>
 
This finds them.

1776783725422.webp



And ... files searched = 0 below!

Code:
v:\> fsearch /t"unquote" v:\*.btm

Matches: 0        Matching files: 0        Total files searched: 0
 
And, though the help says it's OK ...

Code:
v:\> fsearch /=
TCC: (Sys) Access is denied.
 "D:\tc36\FSEARCH.EXE"

That might have been mentioned before. It's the same without /=.

But the full path to the EXE (d:\tc36\fsearch.exe) brings up the FSEARCH dialog.
 
It would be helpful if that fact were included in the help information. So the /T option is for people who do not know regular expressions and want the program to convert their (mostly) plain text into one?

That's correct.

If they don't know regular expressions, I don't know that adding that to the help would bring any enlightenment.
 
Not reproducible here. Did you do something like disable or alias the FSEARCH command?

There's nothing in the OPTION\Commands\DisabledCommands list. And,

Code:
v:\> which fsearch
fsearch is an internal command
 
And now this works whereas it didn't earlier (post #5 ... trying Charles's suggestion)

Code:
v:\> fsearch /b /t"@unquote[[]" *.btm
V:\closetcmd.btm
V:\gettcmdver.btm
V:\tcctr.btm
V:\tcplacement.btm
 
I think it would be nice if the /T option would handle escaping in the usual way for text (default ^). My first thought (though it may be more complex) is that the escape character would just have to be changed to the backslash character in the generated regular expression. So fsearch /t"unquote^[" would become in effect fsearch /e"unquote\[".
 
Back
Top