user3038679
user3038679

Reputation: 71

find a word in a sequence of alphabet chars

Using regexpal.com, I need to find de word banana in a sequence of alphabet characters that also do not include the word ana.

I have tried the following banana((?!ana).)*

and it does not work in the following sentence alfabetwithsbananaandnotana

It highlights everything from semana until ana. I am new with regex, can anyone help out?

Upvotes: 1

Views: 80

Answers (1)

Ωmega
Ωmega

Reputation: 43673

\b(?![a-zA-Z]*ana[a-zA-Z]*ana)[a-zA-Z]*banana[a-zA-Z]*\b

See demo here.

Upvotes: 1

Related Questions