简体   繁体   English

PHP Preg_match_all正则表达式模式

[英]PHP Preg_match_all regexp pattern

I need your help for a pattern i can't do myself. 我需要你帮助我自己做不了的模式。

I got this file : 我收到了这个文件:

    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" />

I have this preg_match_all which works perfectly : 我有这个preg_match_all完美的工作:

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

My problem is i can have simple quotes instead of double, how can i change my pattern to handle it? 我的问题是我可以使用简单的引号而不是双引号,如何更改我的模式来处理它? Example, i need to catch this line like all others: 例如,我需要像所有其他人一样抓住这条线:

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

Thank a lot for your help. 非常感谢你的帮助。

尝试使用正则表达式

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

使用反向引用要求结束报价与开头报价相匹配:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM