Named capture in PHP using regex

前端 未结 2 1205
星月不相逢
星月不相逢 2020-12-13 17:32

How can I use named capture with regex in PHP? Can anyone give me a working example?

2条回答
  •  感情败类
    2020-12-13 18:13

    Doesn't work with replace , only useful for match in php

    $test="yet another test";
    
    preg_match('/(?Pt[^s]+)/',$test,$matches);
    
    var_dump($matches['word']);
    

提交回复
热议问题