I have the following RegEx that is used and working:
/\ B@ (@?\w+(?:::\w+)?)([ \t]*)(\( ( (?>[^()]+) | (?3) )* \))?/x
If this line @extends('template', 'test') correctly groups and gives me what I need.
The problem is that the string contains a closed bracket inside quotation marks - it will not be executed:
@extends('template', 'te)st') gives @extends('template', 'te) as the output
How can I tell this RegEx to ignore the brackets that are inside the quotation marks (either ' or " )
Here is the RegExr trial demo: http://regexr.com/v1?396ci
And here is a list of lines that everyone should go through:
@extends('template', 'test') // working @extends('template', $test) // working @extends('template', 'te()st') // working @extends('template', 'te)st') // broken @extends('template', 'te())st') // broken @extends('template', 'te(st') // broken @extends('template', 'test)') // broken @extends('template', '(test') // broken
I narrowed it down - and I think I need to say
( \( <-- only if not inside quotes ( (?>[^()]+) | (?3) )* \) <-- only if not inside quotes )?
But I can't figure out how to apply this rule to these specific brackets.
source share