使用regex/php读取引文内的文本

mrp*_*atg 5 php regex

我有一个文字标题

This User "The Title Of The Post"
Run Code Online (Sandbox Code Playgroud)

我想抓住INSIDE中的引号,并将其存储在变量中.我怎么用正则表达式和PHP做到这一点?

ope*_*llo 9

http://www.php.net/preg_match

<?php
$x = 'This User "The Title Of The Post"';

preg_match('/".*?"/', $x, $matches);

print_r($matches);

/*
  Output:
  Array
  (
      [0] => "The Title Of The Post"
  )

*/
?>
Run Code Online (Sandbox Code Playgroud)

  • 海报要求"只是引用内容",并且接受的解决方案包括引号.我的解决方案不包括海报要求的引号. (2认同)