正则表达式:在两个字符串之间提取字符串 [英] Regex: Extract string between two strings
本文介绍了正则表达式:在两个字符串之间提取字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
这是我面临的问题
字符串
<块引用>nt/sign-in?wa=wsignin1.0&wtre
需求
我需要从那个字符串中提取以下内容
wsignin1.0
尝试
到目前为止,我已经尝试了以下正则表达式
wa=(.*?)(?=&)
返回:
<块引用>wa=wsignin1.0
wa="不应该在那里
解决方案
也许看看后面?
(?<=wa=)(.+)(?=&wtre)
<块引用>
wsignin1.0
This is the issue I face
The String
nt/sign-in?wa=wsignin1.0&wtre
The Need
From that string I need to extract the following
wsignin1.0
The Attempts
So far I have tried the following Regex
wa=(.*?)(?=&)
This returns:
wa=wsignin1.0
The "wa=" is not supposed to be there
解决方案
Perhaps with a look behind?
(?<=wa=)(.+)(?=&wtre)
wsignin1.0
这篇关于正则表达式:在两个字符串之间提取字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文