PHP Preg_match_all正则表达式模式


PHP Preg_match_all regexp pattern

我自己做不到的模式需要你的帮助。

我得到了这个文件:

    description1="SIOUH : Authentification Cerbere - Acces"
    description2="Acces formulaire authentification SIOUH"
    addheader="Pragma: no-cache "
    method="get"
    url="${AUTH_URL}/login/LoginDispatchAction.do?appId=${APP_ID}&backURL=${APP_URL_ENC}"
    errormessage="Phase 1 : Impossible atteindre le formulaire authentification CERBERE pour SIOUH"
    serveur="yes"
    verifypositive="loginConnectAppliForm"
    logrequest="yes" logresponse="no" />

我有一个preg_match_all,它运行得很好:

preg_match_all  ( '#(.*?)="(.*?)"#s', $contents, $matches, PREG_SET_ORDER ); //Chaque option

我的问题是我可以用简单的引号代替双引号,我如何改变我的模式来处理它?例如,我需要像其他人一样抓住这条线:

parseresponse='name="conversationId" value="|"'

非常感谢你的帮助。

使用反向引用要求结束引号与开始引号匹配:

'#(.*?)=([''"])(.*?)'2#'

尝试使用regex liek这个

^(.*?)=[''"](.*?)[''"]$