title: Regex returns no match in Dart but works in online regex testers
body: <p>I have built a regex which should match valid HTTP headers. It works, sort of, on regexr: <a href="https://regexr.com/4pnk9" rel="nofollow noreferrer">https://regexr.com/4pnk9</a>, with regex <code>^([\w\-])+:(?!\s*$).+$</code>. I am using the global, multi line and case insensitive flags (gim).</p>
  
  <p>However when I implement it in my Flutter project, it does not match anything. Besides that Dart does not provide a way to enable global in RegExp.</p>
  
  <p>Can anyone explain me why this regex works on regexr.com, but not in my Dart tests?</p>
  
  <pre><code>class Validators {
    static final RegExp _headerFieldsRegExp = RegExp(
        "^([\w\-])+:(?!\s*\$).+\$",
        multiLine: true,
        caseSensitive: false);
  
    static bool headerFieldsValid(String headerFields) {
      if (headerFields == null || headerFields.length == 0) {
        return false;
      }
      String match = _headerFieldsRegExp.stringMatch(headerFields);
      if (match == null) {
        return false;
      }
      return headerFields.length == match.length;
    }
  }
  </code></pre>
  
  <pre><code>void main() {
    test('Test validating header fields', () {
      String valid1 = 'Accept: json\nAuthorization: Bearer 12345';
      expect(true, Validators.headerFieldsValid(valid1));
  
      String valid2 = 'Accept: json\nAuthorization: Bearer 12345\n';
      expect(true, Validators.headerFieldsValid(valid2));
  
      String invalid1 = 'Accept: json\nAuthorization:\n';
      expect(false, Validators.headerFieldsValid(invalid1));
  
      String invalid2 = 'Accept: json\n\nAuthorization: Bearer 12345\n';
      expect(false, Validators.headerFieldsValid(invalid2));
    });
  }
  
  </code></pre>