SimpleRegex / SRL-PHP

Simple Regex Language
https://simple-regex.com
MIT License
1.8k stars 112 forks source link

Matching anything between parentheses, including the parenthesis #20

Closed Immortalin closed 8 years ago

Immortalin commented 8 years ago

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

( foo bar -- quux)
(()()()()()))))
(hello world"\)
ghost commented 8 years ago

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.

ghost commented 8 years ago

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.

ghost commented 8 years ago

Why closed? @Immortalin @KarimGeiger

Immortalin commented 8 years ago

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

KarimGeiger commented 8 years ago

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.