gpt4 book ai didi

php - preg_match 检查字符串是否包含在双引号或单引号中

转载 作者:行者123 更新时间:2023-12-02 15:41:20 24 4
gpt4 key购买 nike

谁能告诉我正则表达式,看看某些东西是用双引号还是单引号引起来。

"this is the string"

如果引号根本不存在或在开始和结束时不存在,我希望它返回 false。

最佳答案

preg_match('/^(["\']).*\1$/m', $string);

如果字符串被双引号括起来,将返回 1,否则将返回 0

关于php - preg_match 检查字符串是否包含在双引号或单引号中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5123085/

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