Reputation: 183
I have a string like
January
February
March
I want a regex which matches only uary(January), ruary(February) and ch(march) i.e string after 3 character
I have tried this [a-zA-Z]{1,3}(.*?)$
Its working but giving match in group. I don't want in group. I want pure match
Upvotes: 3
Views: 4237
Reputation: 11508
You can use:
\b\w{3}
\b
is word boundary, then 3 alphanumerics (plus any underscore).
Here'a a demo: https://regex101.com/r/dX8eC7/1
Upvotes: 0
Reputation: 1230
Your regex is actually the kind of thing that would be used for this ($
aside), and the "uary" and what not would be called with $1.
(?<=[a-zA-Z]{3}).*(?=\s|$)
will do in non-javascript languages, without any capture groups.
https://regex101.com/r/iV0tR3/1
Upvotes: 2