title: Evaluating a string against a pattern with RegExp in Flutter
body: <p>I'm trying to evaluate a string against a set list of parameters with RegExp in Flutter. For example, the string must contain at least:</p>
  
  <ul>
  <li>One capital letter</li>
  <li>One lowercase letter</li>
  <li>One number from 0-9</li>
  <li>One special character, such as $ or !</li>
  </ul>
  
  <p>This is basically for a password entry field of an application. I have set things up, firstly using <code>validateStructure</code> as follows: </p>
  
  <pre><code>abstract class PasswordValidator {
    bool validateStructure(String value);
  }
  </code></pre>
  
  <p>Then, I have used the <code>RegExp</code> function as follows: </p>
  
  <pre><code>class PasswordValidatorSpecial implements PasswordValidator {
    bool validateStructure(String value) {
      String pattern =
          r'^(?=.*?[A-Z])(?=.*?[a-z])(?=.*?[0-9])(?=.*?[!@#\$&amp;*~£]).{8,}$';
      RegExp regEx = new RegExp(pattern);
      return regEx.hasMatch(value);
    }
  }
  </code></pre>
  
  <p>This does work well, in a sense that when I pass a string/password through it, it does tell me if at least one of the criteria is not met. However, what I would like to do is for the output to be more specific, telling me which of those criteria isn't met. </p>
  
  <p>For example, if the password were to have everything but a number (from 0-9) I would want to be able to get the output to specifically say that a number is missing, but everything else is present.</p>
  
  <p>How would I adapt my code to be able to do that? I thought perhaps by using conditional 'if' statement, although I don't know how that would work. Thanks!</p>