我有这个字符串:
```yaml
project_id: 524
type:
- content changes
- code changes
production_urls:
- http://produrl.net/special/page
database_tables:
- content
- articles
```
我需要得到yaml
和' ' '之间的文本。所以新的字符串将以project_id...
开始,以...articles
用PHP获得新字符串的最有效方法是什么?
对于正则表达式,只需这样做:
<?php
$string = '```yaml
project_id: 524
type:
- content changes
- code changes
production_urls:
- http://produrl.net/special/page
database_tables:
- content
- articles
```';
$string = preg_replace('#^```yaml(.*)```$#s', '$1', $string);
echo "<pre>".print_r($string, true)."</pre>";
?>