Regular Expressions Hurt My Head

Associate
Joined
21 Sep 2005
Posts
180
Location
Dundee
I have a small exercise to do for Uni as part of a Perl tutorial. I've been trying to accomplish it but have hit a wall.

I have to do a search, within a string, for a 7 letter word that has 'pr' in it and has 'm' as the final letter. These can be both upper or lower case.

So far i have this....

Code:
/(?=\b\w{7}\b)(\b\w*pr\w*\b)/gi

This works great up until the 'm' on the end. I've tried many different variations and i know it's something to do with word boundaries, but i just can't get it to work. I'm close to screaming and my head hurts. Can anyone please point me in the right direction?

Thanks for any help.
 
Thanks, that seems to work. I left the 'm' bit out deliberately as i had tried countless different ways of doing it and figured i would just muddy the water.

Thanks again.
 
Back
Top Bottom