Add regular expression support for searching in files
I'm using pnotepad for several years have been missing this feature all the time.
Thanks in advance.
Add regular expression support for searching in files
I'm using pnotepad for several years have been missing this feature all the time.
Thanks in advance.
There are external programs that do regular-expression searches on files. I use one from active-state perl. It shouldn't be hard to find one. I have noticed that even editors that support regular expressions tend not to support them for find-in-files.
Because I do a lot of this, I recently built some tools to index c-tags and identifiers into a sqlite3 database, which I use from PN2. Since sqlite queries include some pattern matching, the tools allow me to say something like
D:\pn-projects\DEFS.db "select * from refsview where word glob '*DATA*MEMORY' order by path" "?(?) : ?"
The restriction is that I only index identifiers, so patterns are limited to an identifier and they use glob syntax. The advantage is that a database lookup is considerably faster than a scan of several thousand files.
I have the tools up on <http://sites.google.com/site/macthenaief/Home/cindex>
@mac3n Nice, thanks for sharing!
The main thing that's stopped me from supporting regular expressions for find in files so far is that I still want to be able to indicate line numbers for matches. However, most regular expression libraries parse in terms of stream indexes meaning I need to provide some form of extra step to work out the line numbers.
It's possible a short-term fix could be to switch to offsets when using regular expressions.
That accounts for most editors not supporting REs in find-in-files, and most tools that do, not supporting multi-line matches. They split the files into lines, then do a match on each line. It also makes it possible to assume the searched string fits in memory (unless you have lines >2GB).
Ah, that's an approach I hadn't thought of. It would be a shame to not support multi-line search but it might be a good halfway house until I can devote proper time to it.
You must log in to post.