2
I need to capture double quotes with Regex in PHP. I tried using line-breaking recursiveness in several ways, but to no avail. I’ve combed through several topics and researched how to do that, but so far I haven’t 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: https://regex101.com/
Remembering that there is no pattern for the rest, but what I need will always be inside a string with double quotes.
Thank you
In the call of
preg_match_all()
you used some PCRE modifier?– rray
I’m trying with the
multiline (m)
modifier– Aly
But in this example it captures everything in quotes? what’s the problem?
– rray
It only captures the first one, I need it to capture all of them (including if you have more than one on the same line). That is, the recursion is not working...
– Aly
Look at this example in case you’ll need to take everything in position
1
of the array, you can des/comment the example lines to see the difference.– rray
It worked! He took all 317 strings, but in both positions
0
and1
array. Why does it have two (and equal) positions? Edit: I just noticed, the difference is the quotes. Wonderful! Want to post as answer, so I mark as solution response?– Aly
I already put an answer, hahah the most difficult thing was to assemble the regex you did just switched function.
– rray