Possible to do regex search in file *contents*?

General discussion related to "Everything".
Post Reply
Coldblackice
Posts: 79
Joined: Sun Jul 13, 2014 12:20 am

Possible to do regex search in file *contents*?

Post by Coldblackice »

I'm trying to find some particular text in a folder full of log files, but it seems that the "contents:" ability isn't using regex or wildcards. Is it possible to do this?
void
Developer
Posts: 16773
Joined: Fri Oct 16, 2009 11:31 pm

Re: Possible to do regex search in file *contents*?

Post by void »

prefix the content: search function with the regex: modifier:

For example:
regex:content:"^foo bar$"
raccoon
Posts: 1017
Joined: Thu Oct 18, 2018 1:24 am

Re: Possible to do regex search in file *contents*?

Post by raccoon »

:o I would have never guessed to try this! :shock:

What other functions can be stacked this way??
void
Developer
Posts: 16773
Joined: Fri Oct 16, 2009 11:31 pm

Re: Possible to do regex search in file *contents*?

Post by void »

Here is a list of all the search modifiers:
  • ascii:, utf8:, noascii: - Enable or disable fast ASCII case comparisons.
  • case:, nocase: - Match or ignore case.
  • diacritics:, nodiacritics: - Match or ignore accent marks.
  • file:, files:, nofileonly: - Match files only.
  • folder:, folders:, nofolderonly: - Match folders only.
  • path:, nopath: - Match the full path and file name or just the filename.
  • regex:, noregex: - Enable or disable regex.
  • wfn:, wholefilename:, nowfn:, nowholefilename:, exact: - Match the whole filename or match anywhere in the filename.
  • wholeword:, ww:, nowholeword:, noww: - Match whole words or match anywhere in the filename.
  • wildcards:, nowildcards: - Enable or disable wildcards.
file: and folder: modifiers work for all search functions.
Some modifiers can be mixed together, eg: case:path:regex:^foo, while
other modifiers cannot, eg: the regex: search modifier does not support the diacritics: search modifier.

These search functions support all the search modifiers:
  • album:
  • artist:
  • child:
  • comment:
  • content:, ansicontent:, utf8content:, utf16content:, utf16becontent:
  • filelistfilename:
  • genre:
  • parent:, infolder:, nosubfolders:
  • title:
  • type:
These search functions only support some modifiers:
  • endwith: -supports case:/diacritics:/path: modifiers
  • ext: -supports case: modifier
  • filelist: -supports case:/path: modifiers
  • startwith: -supports case:/diacritics:/path: modifiers
raccoon
Posts: 1017
Joined: Thu Oct 18, 2018 1:24 am

Re: Possible to do regex search in file *contents*?

Post by raccoon »

Very cool, and I'll definitely be using this.

If I might suggest, the option for `dbcscontent:`, or `unicodecontent:` as it were to contrast `ansicontent:`, which is simply 16 bit plain 0 BMP unicode strings in windows, ie, usually found in compiled 32 bit software and resources. Easily recognizable in a hex editor as mainly ansi characters separated by null characters most of the time.
Stamimail
Posts: 1122
Joined: Sat Aug 31, 2013 9:05 pm

Re: Possible to do regex search in file *contents*?

Post by Stamimail »

raccoon wrote: Sun Nov 17, 2019 3:31 am :o I would have never guessed to try this! :shock:

What other functions can be stacked this way??
I hope someone will find a way and introduce a wonderful idea on how to make syntax more intuitive.
viewtopic.php?f=4&t=6057
viewtopic.php?f=5&t=6417#p19658
void
Developer
Posts: 16773
Joined: Fri Oct 16, 2009 11:31 pm

Re: Possible to do regex search in file *contents*?

Post by void »

Here's a list of all the aliases for utf16content:

wcharcontent:
unicodecontent:
contentw:
utf16content:
utf16lecontent:

I hope to add a new function in future releases called textcontent: which will treat files as text/plain and use the BOM to determine encoding.
Post Reply