Find a letter in the upper case in the text

2

I'm doing some text checks for password.

I have already localized for a special character but I did not find it for uppercase letter.

I used Regex. For example if the text contains "test" returns false and if it contains "tesTE" returns true.

Can anyone tell me? If it works with Regex too?

I used this to check if my password field has a special character

ExisteCaracterEspecial = Regex.IsMatch(txt_senha.Text, ("[\[\]\^\$\.\|\?\*\+\(\)\~'\!@#%&\-_+={}'""<>:;, ]{1,}"));

I'm using VB.NET

    
asked by anonymous 31.01.2017 / 20:09

1 answer

1

You can do this by using Any f% of LINQ as well.

In VB.NET

  • With LINQ

    Dim existeMaiuscula As Boolean = senha.Any(Function(c) Char.IsUpper(c)) 
    
  • With Regex

    Dim existeMaiuscula As Boolean = Regex.IsMatch(senha, "\p{Lu}")
    

In C #

  • With LINQ

    var existeMaiuscula = senha.Any(c => Char.IsUpper(c));
    
  • With Regex

    var existeMaiuscula = Regex.IsMatch(senha, @"\p{Lu}");
    
31.01.2017 / 20:18