parse method

  1. @override
List<Link> parse()
override

Implementation

@override
parse() {
  String pattern =
      r"(http(s)?:\/\/)?(www.)?[a-zA-Z0-9]{2,256}\.[a-zA-Z0-9]{2,256}(\.[a-zA-Z0-9]{2,256})?([-a-zA-Z0-9@:%_\+~#?&//=.]*)([-a-zA-Z0-9@:%_\+~#?&//=]+)";

  RegExp regExp = RegExp(pattern, caseSensitive: false);

  Iterable<RegExpMatch> allMatches = regExp.allMatches(text);
  List<Link> links = <Link>[];
  for (RegExpMatch match in allMatches) {
    links.add(Link(regExpMatch: match, type: http));
  }
  return links;
}