How to get the shortest rather than longest possible regex match with preg_match()

前端 未结 3 2187
臣服心动
臣服心动 2020-12-03 16:00

I have string similar to this one:

{{something1}} something2 {{something3}} something4

How can I match only \"something1\" using the

3条回答
  •  野趣味
    野趣味 (楼主)
    2020-12-03 16:29

    Try this:

    preg_match('|{{([^}]+)}}|si', $content, $matches);
    
    echo $matches[1];
    

提交回复
热议问题