Pregunta

I have this string( like python doc ):

"""
1 string with two lines
in this area
"""
"""
2 string, but with more "quotes"
"""
"""
3 string
multiline and "multiquote"
"""

I need:

array(
[0] => 1 string with two lines
    in this area

[1] => 2 string, but with more "quotes"
[2] => 3 string
    multiline and "multiquote"

)

But, i have:

/(?<!""")(?<=(?!""").)"(?!""")/im 

And:

/(\x22\x22\x22)[\w\s\d\D\W\S.]+(?\x22\x22\x22)/i
¿Fue útil?

Solución

See this https://eval.in/126887

preg_match_all("/\"{3}(.*?)\"{3}/s", $str, $matches);

Otros consejos

why dont you code it like this

$re = '/"""(.*?)"""/is'; 
$str = '"""
1 string with two lines
in this area
"""
"""
2 string, but with more "quotes"
"""
"""
3 string
multiline and "multiquote"
"""'; 

preg_match_all($re, $str, $matches);
echo "<pre>";
print_r($matches[1]);

output:

Array
(
    [0] => 
1 string with two lines
in this area

    [1] => 
2 string, but with more "quotes"

    [2] => 
3 string
multiline and "multiquote"

)
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top