BoDiE2003
BoDiE2003

Reputation: 1359

Match string with space by regular expression

I'm trying to make this regex ^(?!\-\-\sRoaming) to match with -- Roaming but it doesnt. Am I matching correctly the white space between -- and Roaming ?

Upvotes: 2

Views: 3341

Answers (3)

Bohemian
Bohemian

Reputation: 425033

Try this, which won't match if -- Roaming is anywhere in the input:

^(?!.*--\sRoaming)


Note that you don't need to escape the hyphens.

Upvotes: 1

Dave
Dave

Reputation: 81

Yes you are correctly matching that portion of the Regex. I am a little hazy on Regex but what does the ?! mean? I tried the \-\-\sRoaming part in http://regexpal.com/ and it was working correctly.

Upvotes: 1

aaa
aaa

Reputation: 786

The space is correct. But why wouldnt --\sRoaming work for you?

Upvotes: 1

Related Questions