Page 39 - Dart Language
P. 39

Chapter 16: Regular Expressions




        Syntax



            •  var regExp = RegExp(r'^(.*)$', multiLine: true, caseSensitive: false);


        Parameters




          Parameter            Details

          String source        The regular expression as a String


                               Whether this is a multiline regular expression. (matches ^ and $ at the
          {bool multiline}
                               beginning and end of each line individually not the whole String)

          {bool                If the expression is case sensitive
          caseSensitive}



        Remarks



        Dart regular expressions have the same syntax and semantics as JavaScript regular expressions.
        See http://ecma-international.org/ecma-262/5.1/#sec-15.10 for the specification of JavaScript
        regular expressions.

        This means that any JavaScript resource you find about Regular Expressions online applies to
        dart.


        Examples



        Create and use a Regular Expression



         var regExp = new RegExp(r"(\w+)");
         var str = "Parse my string";
         Iterable<Match> matches = regExp.allMatches(str);


        It's a good idea to use "raw strings" (prefix with r) when writing regular expressions so you can
        use unescaped backslashes in your expression.


        Read Regular Expressions online: https://riptutorial.com/dart/topic/3624/regular-expressions














        https://riptutorial.com/                                                                               34
   34   35   36   37   38   39   40   41   42