Home > Backend Development > PHP Tutorial > 求一个正规表达式

求一个正规表达式

WBOY
Release: 2016-06-20 12:28:37
Original
800 people have browsed it

sss=a&token=asfasdfd我想用正规得到token= 后面的内容 因为token后面没有了东西了 我一时不知道怎么写了token=(.*)  后面写一个什么呢?
Copy after login


回复讨论(解决方案)

token=(.*)
你这样也能获取啊
改成这样好点
token=(.*?)

用parse_str岂不是更好?

$s = 'sss=a&token=asfasdfd';parse_str($s, $arr);print_r($arr);
Copy after login

Array
(
    [sss] => a
    [token] => asfasdfd
)

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template