Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

regex lookarounds, combining lookahead and lookbehind

Tags:

regex

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!

like image 968
exl Avatar asked Mar 08 '13 13:03

exl


1 Answers

You got lookahead part wrong:

(?<=Top Skills & Expertise).*(?=Most Recommended)
like image 81
BartekB Avatar answered Sep 27 '22 16:09

BartekB