gpt4 book ai didi

php - 这个正则表达式是什么意思?

转载 作者:可可西里 更新时间:2023-10-31 22:16:01 25 4
gpt4 key购买 nike

谁能告诉我它试图准确匹配什么?

$exp = '/[\s]+col[\s]*=[\s]*"([^"]*)"/si';

最佳答案

如果添加 /x,您可以编写带注释的正则表达式修饰符。所以这是一个冗长的文档版本(对于复杂的版本总是可取的):

$exp = '/
[\s]+ # one or more spaces
col # col
[\s]* # zero or more spaces
= # =
[\s]* # spaces
" # "
([^"]*) # anything but " and zero or more of it
" # "
/six';

你有时也会看到 [^<">]代替 [^"]使此类正则表达式对格式错误的 html 更具弹性。

关于php - 这个正则表达式是什么意思?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4566228/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com