Php 正则表达式匹配三个引号字符串
我有以下字符串(如python文档): 我需要:Php 正则表达式匹配三个引号字符串,php,regex,pcre,Php,Regex,Pcre,我有以下字符串(如python文档): 我需要: array( [0] => 1 string with two lines in this area [1] => 2 string, but with more "quotes" [2] => 3 string multiline and "multiquote" ) 但是,我有: /(?<!""")(?<=(?!""").)"(?!""")/im 看到这个了吗 看到这个了吗 你为什么不这
array(
[0] => 1 string with two lines
in this area
[1] => 2 string, but with more "quotes"
[2] => 3 string
multiline and "multiquote"
)
但是,我有:
/(?<!""")(?<=(?!""").)"(?!""")/im
看到这个了吗
看到这个了吗
你为什么不这样编码呢
$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"
)
$re='/''(.*)“/is';
$str='“”“
1个带两行的字符串
在这个地区
"""
"""
2个字符串,但带有更多“引号”
"""
"""
3串
多行和“多引号”
"""';
预匹配全部($re,$str,$MATCHS);
回声“;
打印($matches[1]);
输出:
大堆
(
[0] =>
1个带两行的字符串
在这个地区
[1] =>
2个字符串,但带有更多“引号”
[2] =>
3串
多行和“多引号”
)
为什么不这样编码呢
$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"
)
$re='/''(.*)“/is';
$str='“”“
1个带两行的字符串
在这个地区
"""
"""
2个字符串,但带有更多“引号”
"""
"""
3串
多行和“多引号”
"""';
预匹配全部($re,$str,$MATCHS);
回声“;
打印($matches[1]);
输出:
大堆
(
[0] =>
1个带两行的字符串
在这个地区
[1] =>
2个字符串,但带有更多“引号”
[2] =>
3串
多行和“多引号”
)
preg_match_all("/\"{3}(.*?)\"{3}/s", $str, $matches);
$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"
)