Capturing content from double quotation marks with recursion with RegEx

2

I need to capture the quotes in double quotation marks with RegEx in PHP. I tried to use recursion with line break in several ways, but to no avail. I browsed several topics and I researched how to do this, but so far I have not been able to.

Block example:

mes "teste de mensagem";
input "blablabla";
switch("este é um":"placeholder");
end script;

Last code I used:

[.*\n]?"(.+?)"[.*\n]?(?1)*?

To test I'm using: link

Remembering that there is no pattern for the rest, but what I need will always be inside a double-quoted string.

Thank you

    
asked by anonymous 06.08.2015 / 14:29

1 answer

1

To catch all captured instances use the preg_match_all () function and not preg_match (). The zero index has everything that was captured, while the others contain the result (capture) of the groups that are the expressions in parentheses.

    
07.08.2015 / 02:08