dragonmnl
dragonmnl

Reputation: 15548

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/

Upvotes: 2

Views: 41

Answers (1)

vks
vks

Reputation: 67968

[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

Upvotes: 3

Related Questions