简体   繁体   中英

How to match non-capturing group

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/

[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.

https://regex101.com/r/cJ6zQ3/2

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM