SimpleRegex/SRL-PHP

Matching anything between parentheses, including the parenthesis

Immortalin opened this issue · 5 comments

Hi, I have been trying to build a query that matches the following string but without much success:

( foo bar -- quux)
(()()()()()))))
(hello world"\)

I think, this problem is about backslashes.
This is not working:

begin with literally "("
any of (one of '()-\"', letter, whitespace new line) never or more
literally ")" must end

But this is working:

begin with literally "("
any of (one of '()-\\"', letter, whitespace new line) never or more
literally ")" must end

https://simple-regex.com/build/57c69abe2f76a

I just escaped backslash.

literally '\' => The SRL Query contains an error: Invalid string ending found.

I think literally '\' mustn't cause an error. Backslashes should be escaped while building query.

@nsgonultas I no longer need the particular regex anymore, but I will reopen it as bug for now

I don't think literally '\' is a bug, since it would be inconsistent behaviour. Backslash escapes every \, ' or " no matter what follows. In PHP, you can't do a echo '\'; either.

If any, then I'd add something like backslash (as seen with whitespace) as a character.