Regular expression to extract link text from anchor tag

前端 未结 3 1368
不思量自难忘°
不思量自难忘° 2020-12-20 01:15

i want to get the word Asarum in the below line:

 

        
3条回答
  •  陌清茗
    陌清茗 (楼主)
    2020-12-20 01:43

    Use this code, to match the text to a specific regex, instead of replacing everything else:

    preg_match('/(.+?)<\/a>/i', $link, $matches);
    

    $matches[1] will now contain the text you're looking for.

提交回复
热议问题