Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pcregrep Error -46 while using simple recursive regex #24

Closed
michaeltyson opened this issue Oct 6, 2021 · 4 comments
Closed

pcregrep Error -46 while using simple recursive regex #24

michaeltyson opened this issue Oct 6, 2021 · 4 comments

Comments

@michaeltyson
Copy link

michaeltyson commented Oct 6, 2021

Hi!

This regex:

(((?>[^()]+)|(?R))*)

Causes pcregrep/pcre2grep to bail immediately with error -46:

> pcre2grep '(((?>[^()]+)|(?R))*)' test.txt
pcre2grep: pcre2_match() gave error -46 while matching this text:
...
@zherczeg
Copy link
Collaborator

zherczeg commented Oct 6, 2021

I cannot check it without a some kind of input. Anyway, #22 might fix this. Could you check it?

@michaeltyson
Copy link
Author

michaeltyson commented Oct 6, 2021

It seems to occur on any input at all:

> echo hello world > test.txt
> pcre2grep '(((?>[^()]+)|(?R))*)'  test.txt
pcre2grep: pcre2_match() gave error -46 while matching this text:

hello world

pcre2grep: Error -46, -47, -53 or -63 means that a resource limit was exceeded.
pcre2grep: Check your regex for nested unlimited loops.

I'm afraid I don't have the time right now to get a build working (I just installed the homebrew version).

@zherczeg
Copy link
Collaborator

zherczeg commented Oct 6, 2021

Hm, this pattern looks really like an unbound regex, since it recursively call itself without matching anything.

Regex101 also complains: https://regex101.com/r/qqLt6Z/1
The match was halted because your expression contains a recursive loop. This means either that the whole pattern, or a subpattern, has been called recursively for the second time at the same position in the subject string.

@michaeltyson
Copy link
Author

Ah, okay, fair enough. I was just using it as I found it Out There On The Internet and it seemed to be being presented as an accepted technique for recursively matching bracket pairs. Guess I need to keep digging.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants