Find a uppercase letter in the text

Asked

Viewed 138 times

2

I’m doing some text checks for password.

I’ve already located for special character but I couldn’t find for high letter.

I used Regex. For example if the text contains "test" returns false and if it contains "test" 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 am using VB.NET

  • 1

    @rubStackOverflow I think if AP tagged C# is because it accepts response in any of the languages. It would not have to remove the tag.

  • Got it @jbueno

  • @rubStackOverflow I think, right :p Let’s see what it says

  • Better to pass than to miss :)

1 answer

1


It is possible to do this using the Any of LINQ also.

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}");
    
  • It worked perfectly @jbueno thank you very much!

Browser other questions tagged

You are not signed in. Login or sign up in order to post.