正则表达式:找到在一件事情之后在另一件事情之前发生的一切 [英] Regex: find whatever comes after one thing before another thing

查看:53
本文介绍了正则表达式:找到在一件事情之后在另一件事情之前发生的一切的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想找到在 s = 之后,在& 之前或字符串末尾的所有内容.例如,如果字符串为

I want to find anything that comes after s= and before & or the end of the string. For example, if the string is

t = qwerty& s = hello& p = 3

t=qwerty&s=hello&p=3

我想得到 hello .如果字符串是

I want to get hello. And if the string is

t = qwerty& s = hello

t=qwerty&s=hello

我也想得到 hello

谢谢!

推荐答案

\ bs =([[^&] +)并抓住 $ 1 应该足够了,不?

\bs=([^&]+) and grabbing $1should be good enough, no?

添加了单词锚!否则,它也将与 herpies dongles ...

edit: added word anchor! Otherwise it would also match for herpies, dongles...

这篇关于正则表达式:找到在一件事情之后在另一件事情之前发生的一切的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆