正则表达式字符串之间的所有内容
我有一个可以以两种不同方式查看的字符串:
foo=bar (everything after "=" including any other character)
or
foo=bar&bar (everything between "=" and "&")
我想在这种特殊情况下使用正则表达式,如何替换 foo
的值
I have a string that can look in two different ways:
foo=bar (everything after "=" including any other character)
or
foo=bar&bar (everything between "=" and "&")
I would like to use a regexp for this particular case, how could I replace the value of foo
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
匹配
(foo)=([^&]+)
将捕获foo
以及等号相应右侧内容的值。我不确定你到底想用它做什么。Matching
(foo)=([^&]+)
will capturefoo
and the value of the stuff on the corresponding right-hand side of the equals sign. I'm not sure exactly what you're looking to do with it.