bfs icon indicating copy to clipboard operation
bfs copied to clipboard

Support more regex types

Open tavianator opened this issue 7 years ago • 12 comments

Findutils offers

  • [ ] findutils-default
  • [ ] awk
  • [ ] egrep
  • [x] ed
  • [x] emacs
  • [ ] gnu-awk
  • [x] grep
  • [ ] posix-awk
  • [x] posix-basic
  • [ ] posix-egrep
  • [x] posix-extended
  • [ ] posix-minimal-basic
  • [x] sed

tavianator avatar Apr 25 '17 00:04 tavianator

I think that posix-extended is the best of those, and I am glad that that's supported.

One option that's not in that list, that even find does not have, is PCRE. Can you please add support for that? (grep supports PCRE with the -P switch.)

kaushalmodi avatar Oct 13 '17 21:10 kaushalmodi

I'd choose https://github.com/kkos/oniguruma.

@tavianator if you don't mind, I might do this task. :)

data-man avatar Oct 18 '21 11:10 data-man

Feel free! I'm not too familiar with oniguruma, but it looks like it might be customizable enough to be compatible with the various GNU regex flavours.

tavianator avatar Oct 18 '21 12:10 tavianator

Ok.

What do you prefer?

  • to use system library
  • keep it in this repository (personally I'd prefer it)

data-man avatar Oct 18 '21 13:10 data-man

In this case I'd prefer to link with the system library rather than vendoring it

tavianator avatar Oct 18 '21 13:10 tavianator

Got it! I asked because many programmers don't like to add dependencies. :)

data-man avatar Oct 18 '21 14:10 data-man

The first small step: #81

data-man avatar Jan 24 '22 02:01 data-man

Probably PEG can be added to your list. E.g. using awesome https://github.com/soasme/PeppaPEG. It would be a unique feature!

data-man avatar Jan 24 '22 03:01 data-man

I'm a fan of PEGs (and that project name is a laugh) but I'm not sure what the utility is for bfs. I don't expect people to search for files like bfs -peg 'name = num "." ext; num = [0-9]+; ext = "jpg" | "png";'

tavianator avatar Jan 24 '22 14:01 tavianator

bfs -fpeg <filename> and users can keep PEGs somewhere.

Another great idea: fuzzy match. Something like Reverse Engineering Sublime Text’s Fuzzy Match.

data-man avatar Jan 24 '22 16:01 data-man

@data-man Any idea why the new test from https://github.com/tavianator/bfs/commit/c898af13a671ee92a056467d324f16823594eb1c fails when building with Oniguruma?

tavianator avatar Jan 30 '22 02:01 tavianator

Oh wait, I see. Turns out that \(thing\|other\) is not actually part of POSIX basic regular expressions. But glibc supports it as an extension. Will revert that.

tavianator avatar Jan 30 '22 02:01 tavianator