search

Home  >  Q&A  >  body text

php regular problem

$dsnStr='mysql://root:root@127.0.0.1:3306/test';
preg_match('/^(.?)://(.?): (.?)@(.?):([0-9]{1, 6})/(.*?)$/',trim($dsnStr),$matches);
I would like to ask why this cannot be matched. $natches is an empty array. How can I change it to match it?

PHPzPHPz2769 days ago649

reply all(2)I'll reply

  • 滿天的星座

    滿天的星座2017-05-16 12:04:42

    preg_match('/^(.*?):\/\/(.*?):(.*?)@(.*?):([0-9]{1,6})(.*?)$/',trim($dsnStr),$matches);
    
    
    

    reply
    0
  • 某草草

    某草草2017-05-16 12:04:42

    reply
    0
  • Cancelreply