Regex pattern problem

  • Thread starter Thread starter C.
  • Start date Start date
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
 
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
 
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
 
Back
Top