-1

I'm using C#. When I test this pattern at https://regexr.com/ it works but it doesn't work in my application.

I want to disallow whitespace in the input(username and password).

gregmac
  • 23,373
  • 10
  • 86
  • 115
Behnam Rasooli
  • 692
  • 5
  • 19
  • 1
    You may benefit from [Reference - Password Validation](https://stackoverflow.com/questions/48345922/reference-password-validation) – ctwheels Apr 17 '18 at 17:33

1 Answers1

1

The / surrounding characters are delimiters for the regex itself -- for example, in javascript you can use those in place of quotes: "Abcd".match(/^\S*$/)

In C#, you must use quotes, so you can write your code simply as:

Regex.IsMatch("Abcd", @"^\S*$")
gregmac
  • 23,373
  • 10
  • 86
  • 115