String with spaces - Regex IsMatch returns true when it should return false

1

I have the following Regex

(?=.*\d)(?!.*\s)(?=.*[a-zA-Z\s]).{6,12}

If I do tests on site that test Regex, it works, in the Model annotation of the view to validate it works, but when I do in the regex.IsMatch(" qqq11") service it returns true , where it should bring false .

    
asked by anonymous 11.07.2014 / 14:05

1 answer

2

There may be some difference between how these sites and the Regex class works.

Testing here some sites return true to this value, others return false , what you can try to do is change the regex to get the start and end of the line

^(?=.*\d)(?!.*\s)(?=.*[a-zA-Z\s]).{6,12}$
    
11.07.2014 / 15:13