preg_match 中的匹配双引号
我想匹配下面的模式并获得单词目标。
输入类型=“隐藏”名称=“标题”值=“目标”>
我尝试这样做但徒劳。
preg_match('@(?:<INPUT TYPE="HIDDEN" NAME="TITLE" VALUE=")(.*)(?:">)@',$data,$matches);
我认为问题是因为双引号
我也尝试了 \" 但仍然失败......
I want to match the pattern below and obtain the word target.
INPUT TYPE="HIDDEN" NAME="TITLE" VALUE="target ">
I try this but in vain.
preg_match('@(?:<INPUT TYPE="HIDDEN" NAME="TITLE" VALUE=")(.*)(?:">)@',$data,$matches);
I think the problem is because of double quote
I also try \" but still fail...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
试试这个:
Try this:
它失败只是因为你的模式中有一个双空格(用
_
标记):删除那里的一个空格并且它可以工作,无论如何,这将是我从头开始的尝试,不区分大小写,或者使用 < code>" 或
'
虽然我不确定它是否是您想要的name
必须是title
的一部分在这种情况下我必须稍微编辑一下。It fails simply because you have a double space in your pattern in here (marked with
_
):Remove one space there and it works, anyway here would be my attempt from scratch, case insensitive and either with
"
or'
though I'm not sure if it's part of what you want thatname
has to betitle
in which case I'd have to edit it a bit.你很接近...你需要匹配usng()。看起来你有一个额外的 )
[^"] - 除 "
( ) 之外的任何字符 - 匹配部分
You're close... You need to match usng (). It looks like you've got an extra )
[^"] - any character other than "
( ) - matching part