title: How to use RegEx in Dart?
body: <p>In a Flutter application, I need to check if a string matches a specific RegEx. However, the RegEx I copied from the JavaScript version of the app <em>always</em> returns false in the Flutter app. I verified on <a href="https://regexr.com/" rel="noreferrer">regexr</a> that the RegEx is valid, and this very RegEx is already being used in the JavaScript application, so it should be correct.</p>
  
  <p>Any help is appreciated!</p>
  
  <p>RegEx : <code>/^WS{1,2}:\/\/\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}:56789/i</code></p>
  
  <p>Test Code : </p>
  
  <pre><code>RegExp regExp = new RegExp(
    r"/^WS{1,2}:\/\/\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}:56789/i",
    caseSensitive: false,
    multiLine: false,
  );
  print("allMatches : "+regExp.allMatches("WS://127.0.0.1:56789").toString());
  print("firstMatch : "+regExp.firstMatch("WS://127.0.0.1:56789").toString());
  print("hasMatch : "+regExp.hasMatch("WS://127.0.0.1:56789").toString());
  print("stringMatch : "+regExp.stringMatch("WS://127.0.0.1:56789").toString());
  </code></pre>
  
  <p>Output : </p>
  
  <pre><code>allMatches : ()
  firstMatch : null
  hasMatch : false
  stringMatch : null
  </code></pre>