Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6902145
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T07:45:42+00:00 2026-05-27T07:45:42+00:00

I came across article which explains how to do password strength validation. I am

  • 0

I came across article which explains how to do password strength validation.

I am having a problem with the errors I am encountering. One error states: Cannot implicitly convert type 'System.Text.RegularExpressions.Match' to 'bool' which is on line if (Regex.Match(password, @"/\d+/",...

The other error says: Operator '&&' cannot be applied to operands of type 'System.Text.RegularExpressions.Match' and 'System.Text.RegularExpressions.Match' which happens on line where AND or && statement is.

I don’t understand why Regex statement isn’t converting to bool type? And second problem is probably connected to the first one.

How can I fix this?

enum PasswordScore
{
    Blank = 0,
    VeryWeak = 1,
    Weak = 2,
    Medium = 3,
    Strong = 4,
    VeryStrong = 5
}

private static PasswordScore CheckStrength(string password)
{
    int score = 1;

        if (password.Length < 1)
            return PasswordScore.Blank;
        if (password.Length < 4)
            return PasswordScore.VeryWeak;

        if (password.Length >= 8)
        score++;
        if (password.Length >= 12)
            score++;
        if (Regex.Match(password, @"/\d+/", RegexOptions.ECMAScript))
            score++;
        if (Regex.Match(password, @"/[a-z]/", RegexOptions.ECMAScript) &&
            Regex.Match(password, @"/[A-Z]/", RegexOptions.ECMAScript))
            score++;
        if (Regex.Match(password, @"/.[!,@,#,$,%,^,&,*,?,_,~,-,£,(,)]/", 
            RegexOptions.ECMAScript))
            score++;

        return (PasswordScore)score;
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T07:45:43+00:00Added an answer on May 27, 2026 at 7:45 am

    You need to use IsMatch, not Match. IsMatch returns a bool, while Match returns a Match object which gives you more detail (captured groups, etc)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

1) I came across THIS ARTICLE today, which states: The most popular method in
I recently came across this article which explains how to use HTML5 tags in
I came across the following article which got me interested in this particular problem.
I came across a printed article by Bertrand Meyer where he states that tests
I came across a few articles like this one , which suggest that some
I came across a php article about regular expressions which used (.*?) in its
I came across this webpage in which the date of the article is an
I came across this article written by Andrei Alexandrescu and Petru Marginean many years
I came across an article about Car remote entry system at http://auto.howstuffworks.com/remote-entry2.htm In the
I came across this article discussing why the double-check locking paradigm is broken in

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.