Regex pattern problem

C

C.

Hi,

Trying to whip up a Regex pattern that will match the word Directive
followed by 4 or more numbers that does NOT end with Home Page.

Directive 1234 hello world //Should match

Directive 1234 hellow world Home Page //Should not match

I tried:

Regex.IsMatch(data, @"^Directive \d\d\d\d.*[^(Home Page)]$",
RegexOptions.IgnoreCase)

but it is not working properly.

Thanks,

Chris
 
J

jj

Hello

The expression to match four consecutive numbers can be \d{4}. for a
single space, it is \s.
So, I suppose if this expression will match your home page:
\d{4}\shello\sworld

Instead of searching for NOT= home page, I would suggest that you
search for home page. So, whatever fails this expression is not your
home page...Do not forget to specify ignore case expressions or
commands if you require so.

Regards,
Jim
 
A

Arne Vajhøj

C. said:
Trying to whip up a Regex pattern that will match the word Directive
followed by 4 or more numbers that does NOT end with Home Page.

Directive 1234 hello world //Should match

Directive 1234 hellow world Home Page //Should not match

I tried:

Regex.IsMatch(data, @"^Directive \d\d\d\d.*[^(Home Page)]$",
RegexOptions.IgnoreCase)

but it is not working properly.

[] is for sets.

My guess would be:

@"^Directive \d{4} ((?!Home Page$).)*"

but it i snot working either.

Arne
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top