This is my input string
这是输入字符串
=abc123&
I need to match the alphanumeric portion without capturing = and &.
我需要匹配不捕获=和&的字母数字部分。
The solution I found is to use a non-capturing group like:
我发现的解决方案是使用非捕获组,比如:
(?:=)[a-zA-Z0-9]+
The issue is that this matches
问题是,它匹配
=abc123
including = which I don't want to be included.
包含=我不想包含在内。
I tested the regex with http://www.regexr.com/
我使用http://www.regexr.com/测试了regex
1 个解决方案
#1
3
[a-zA-Z0-9]+
You can simply use this.Or
你可以使用这个
=([a-zA-Z0-9]+)(?=&)
You can use this and grab the group 1
.See demo.
您可以使用这个并获取组1。看到演示。
https://regex101.com/r/cJ6zQ3/2
https://regex101.com/r/cJ6zQ3/2
#1
3
[a-zA-Z0-9]+
You can simply use this.Or
你可以使用这个
=([a-zA-Z0-9]+)(?=&)
You can use this and grab the group 1
.See demo.
您可以使用这个并获取组1。看到演示。
https://regex101.com/r/cJ6zQ3/2
https://regex101.com/r/cJ6zQ3/2