Php 如何确保正则表达式两次都匹配?

Php 如何确保正则表达式两次都匹配?,php,regex,Php,Regex,我目前使用以下正则表达式(在PHP中): 基本上,它工作正常,但由于(.*),它与第一项和第二项的内容都匹配。我尝试了多种方法,但无法让它将以下字符串识别为两个匹配项而不是一个匹配项 ---- POST /users/{user-id}/relationship Modify the relationship between the current user and the target user. *Required scope: relationships* ### Parameter

我目前使用以下正则表达式(在PHP中):

基本上,它工作正常,但由于(.*),它与第一项和第二项的内容都匹配。我尝试了多种方法,但无法让它将以下字符串识别为两个匹配项而不是一个匹配项

----
POST /users/{user-id}/relationship

Modify the relationship between the current user and the target user. 
*Required scope: relationships*

### Parameters
- access_token: A valid access token.
- action: One of follow/unfollow/block/unblock/approve/deny.

### Example response
```
    {
        "meta": {
            "code": 200
        }, 
        "data": {
            "outgoing_status": "requested"
        }
    }
```

----

----
GET /users/{user-id}/relationship

Modify the relationship between the current user and the target user. 
*Required scope: relationships*

### Parameters
- access_token: A valid access token.

----
有人知道如何做到这一点吗?谢谢


更新:请原谅我不够清楚。我想匹配Markdown水平分隔符(---)之间的所有内容,以便它们形成两个块,都是API方法描述

尝试通过替换以下内容使其不贪婪:

.*

更新:再次检查您的正则表达式后,我不得不再做一些更正,以下内容现在对我有效:

preg_match_all('#\s*-{3,}\s(?:POST|GET|PUT|DELETE)\s(?:[\w/{}-]*)\s+(.*?)\s+-{3,}\s*#is',
                $str, $m, PREG_SET_ORDER);

这看起来像json。。。为什么不使用一个php JSON函数呢?你说你已经尝试了很多东西。你到底试过什么?你能重新格式化问题并提供输入和预期匹配的样本吗?更新了问题,样本输入已经存在。
.*?
preg_match_all('#\s*-{3,}\s(?:POST|GET|PUT|DELETE)\s(?:[\w/{}-]*)\s+(.*?)\s+-{3,}\s*#is',
                $str, $m, PREG_SET_ORDER);