PHP 不改变引号中的颜色
我想更改单引号内文本的颜色,但我也想更改括号的颜色,只要它们不在引号中即可。这就是我所拥有的,但它没有按计划工作。
"/([^'])\((.*?)\)([^']+)/is" => "$1<span style=\"color: ".$ccode['green']."\">(</span>$2<span style=\"color: ".$ccode['green']."\">)</span>$3"
我使用 preg 替换,这只是数组的一部分。有什么想法吗?
I want to change the color of text inside single quotes, but i have also want to change the color of parenthasis as long as they arent in quotes. this is what i have but its not working as planned.
"/([^'])\((.*?)\)([^']+)/is" => "$1<span style=\"color: ".$ccode['green']."\">(</span>$2<span style=\"color: ".$ccode['green']."\">)</span>$3"
Im using preg replace and this is just a part of the array. any ideas?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我建议使用可用的优秀在线正则表达式测试器之一。一个很好的例子是 http://www.regextester.com/ 您的正则表达式很可能是没有按照您的预期进行解析。使用视觉测试仪有助于查明问题。
I would recommend using one of the fine online regex testers available. A good example of one is at http://www.regextester.com/ More than likely your regex isn't parsing as you expect. Using a visual tester helps pinpoint the problem.