rich_string_parser 1.0.0 copy "rich_string_parser: ^1.0.0" to clipboard
rich_string_parser: ^1.0.0 copied to clipboard

outdated

A dart string parser for parsing multible different formats.

rich_string_parser #

Parse multible different values in one string.

install #

dependencies:
  rich_string_parser: ^1.0.0

Usage #

A simple usage example:

import 'package:rich_string_parser/rich_string_parser.dart';

main() {
  List<dynamic> result = runParser(
    'text to be parsed example@example.com @(123|example)',
    [
      EmailParser(),
      LinkParser(),
      MentionParser(),
    ]
  );

  print(result); // >> ['text to be parsed ' Instance of 'EmailMatch', ' ', Instance of 'MentionMatch']
}

Create own parser #

import 'package:rich_string_parser/rich_string_parser.dart';

class OwnMatch {
  String value;
  OwnMatch(
    this.value,
  );
}

class OwnParser extends Parser {
  RegExp regex = RegExp(
    '(hello)',
    multiLine: true,
    unicode: true
  );

  @override
  OwnMatch converter(String own) {
    return OwnMatch(
      own
    );
  }
}

main() {
  List<dynamic> result = runParser(
    'text to be parsed (hello)',
    [
      EmailParser(),
      LinkParser(),
      OwnParser(),
    ]
  );

  print(result); // >> ['text to be parsed ', Instance of 'OwnMatch']
}

Features and bugs #

Please file feature requests and bugs at the issue tracker.

0
likes
35
pub points
0%
popularity

Publisher

unverified uploader

A dart string parser for parsing multible different formats.

Repository (GitHub)
View/report issues

License

MIT (license)

More

Packages that depend on rich_string_parser