Regex

  • Thread starter Thread starter Naveed Anwar Kharadi
  • Start date Start date
N

Naveed Anwar Kharadi

Hi people !!!
I want to write a regular expression that fails when it finds two consecutive slashes (//) in the provided data.
E.g.
Data = "asdf//fghkj"
Regex.IsMatch(Data) returns false.
 
Try this:

!Regex.IsMatch(Data,"//")

Eddie

Hi people !!!
I want to write a regular expression that fails when it finds two consecutive slashes (//) in the provided data.
E.g.
Data = "asdf//fghkj"
Regex.IsMatch(Data) returns false.
 
Please write your posts in plain text.

Regex.IsMatch(@"^([^/]|/[^/])*$") should do what you want.

Niki

Naveed Anwar Kharadi said:
Hi people !!!
I want to write a regular expression that fails when it finds two
consecutive slashes (//) in the provided data.
 
Niki,
Regex.IsMatch(@"^([^/]|/[^/])*$") should do what you want.

You mean, Regex.IsMatch(Data, @"^([^/]|/[^/])*$"), of course - with the
inclusion of that first parameter - but as no escape characters are
involved, why all the complication?

I'm concerned, here, that there may be circumstances where the simpler
!Regex.IsMatch(Data,"//") that I would use, would be inadequate?

Eddie
 
Back
Top