Matching 'menu_1_29_training' not 'menu_2_8_priv_training'

Any questions involving matching text strings to patterns - the pattern is called a "regular expression."

Moderator: General Moderators

Post Reply
Glycerine
Forum Commoner
Posts: 39
Joined: Wed May 07, 2008 2:11 pm

Matching 'menu_1_29_training' not 'menu_2_8_priv_training'

Post by Glycerine »

I would like a regex that matches

menu_2_8_training

But not

menu_2_8_private_training

I have

Code: Select all

 
(menu_.*?_([^_]*)_training)
for my regex but it doesn't work :banghead:

I would like to literally match 'menu_' then next word after '_' to be anything but not '_'... again with the next word after 2nd '_' to be anything BUT an '_'
- then literally match the 'training'

menu_*_*_training would match but menu_*_*_private_training wouldn't - Any help and I'll buy you a beer - and deliver it... to ANYWHERE. I hope my babbly makes some sense.

Thanks in advance.
User avatar
prometheuzz
Forum Regular
Posts: 779
Joined: Fri Apr 04, 2008 5:51 am

Re: Matching 'menu_1_29_training' not 'menu_2_8_priv_training'

Post by prometheuzz »

Code: Select all

'/^menu_([^_]+)_([^_]+)_training$/'
Glycerine
Forum Commoner
Posts: 39
Joined: Wed May 07, 2008 2:11 pm

Re: Matching 'menu_1_29_training' not 'menu_2_8_priv_training'

Post by Glycerine »

Thanks again prometheuzz - once again my saviour -
User avatar
prometheuzz
Forum Regular
Posts: 779
Joined: Fri Apr 04, 2008 5:51 am

Re: Matching 'menu_1_29_training' not 'menu_2_8_priv_training'

Post by prometheuzz »

Glycerine wrote:Thanks again prometheuzz - once again my saviour -
Hey Jay, you're welcome of course!

Regards,

Bart.
User avatar
prometheuzz
Forum Regular
Posts: 779
Joined: Fri Apr 04, 2008 5:51 am

Re: Matching 'menu_1_29_training' not 'menu_2_8_priv_training'

Post by prometheuzz »

Glycerine wrote:Thanks again prometheuzz - once again my saviour -
... oh, and Duvel is my brew, btw!
; )
Post Reply