Reputation: 1
I want to catch all of the cases that are exactly called number
and then all of the cases where number is surrounded by underscores, for example hey_number
, number_hey
or hey_number_hey
, the thing is that I don't want to catch cases like hey_numbers
or hey_numberrr
I did end up with
(^number$)|(.*[_]{1}number.*)|(.*number[_]{1}.*)
but it still catches hey_numbers
Upvotes: 0
Views: 64
Reputation: 6229
Applying this expression
(?:\w+_|\b)number(?:_\w+|\b)
on this text:
hey_number, number_hey or hey_number_hey, the thing is that I don't want to catch cases like hey_numbers or hey_numberrr or nnumber or nnumber_chesu
you get:
hey_number
number_hey
hey_number_hey
You can try it with this tester.
Upvotes: 2