ZTree.com  | ZEN  | About...  

 Index   Back

[Q] Searchin in files   [Q]

By: Ben Kent       
Date: Aug 23,2023 at 19:57
In Response to: [Q] Searchin in files (Walt)

> Is there a way to search within a file for spaces/wild characters?
>
> I want to find an 8 followed by a number surrounded by spaces.
> IOW " 8|D " [VEdit syntax]
>
> Thanks
> W

Walt

The nearest that ZTree supports is the * wildcard, but that matches any number of characters, i.e. search for this without the quotes
" 8* "
It wouldn't be so bad if the ? (single character) wildcard was also supported, which would lead to fewer false positives for your requirement.


Note:
File spec supports "Enclose a group or range of characters" (search the help), enter like this
Space,Alt-[,0123456789,Alt-],Space
but file search does not support it, so no good for your requirement, you could ZEP for file search to support that, or as I would like regular expressions, that would need a F? toggle or a "RE:" prefix in the search string, as many people don't like/understand regular expressions.


For non-ZTree commandline ways, which could be run from eXecute or the F9 menu

Pure Windows
findstr /r /C:" 8[0-9] " C:\dir\*.*
That has very basic RE support.

Powershell, but only suitable for small files
Get-ChildItem -Path C:\dir -File | % {$a=$_; Write-Host $a.fullname; Get-Content -path $a.fullname -force | Where-Object {$_ -match ' 8\d '} }
Powershell uses .Net and so has rich RE support.


As GoSlow2GoFast suggested dedicated grep like tools will probably be quicker.

Ben

121 views      
 

Messages in this Thread

 
96,456 Postings in 12,197 Threads, 350 registered users, 102 users online (0 registered, 102 guests)
Index | Admin contact |   Forum Time: Sep 30, 2023 - 5:33 am UTC  |  Hits:58,243,290  (8,037 Today )
RSS Feed