0

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

1 Answer 1

2

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.