exl
exl

Reputation: 1853

regex lookarounds, combining lookahead and lookbehind

I am trying to grab the words after "Expertise" and before "Most" in the following string:

"Top Skills & Expertise   Project Management  Cooking  Childcare  Tutoring       Most Recommended"

Based on examples, I think that I should be using this:

(?<=Top Skills & Expertise).*(Most Recommended?=)

But that doesn't seem to work, so I use this:

(?<=)Top Skills & Expertise.*Most Recommended(?=)

Of course, in the second case, the "Top Skills & Expertise" and the "Most Recommended" are consumed and returned, which I don't want.

I"m sure there is just something simple that I'm missing here. Any guidance for a regex newbie will be appreciated!!

Thanks!

Upvotes: 7

Views: 11825

Answers (1)

BartekB
BartekB

Reputation: 8650

You got lookahead part wrong:

(?<=Top Skills & Expertise).*(?=Most Recommended)

Upvotes: 9

Related Questions