You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Find all times, dates, links, phone numbers, emails, ip addresses, prices, hex colors, and credit card numbers in a string.
We did the hard work so you don't have to.
Installation
Once you have added a dependency in your pubspec.yaml, you'll need to import the library like so:
import 'package:common_regex/common_regex.dart'
Usage
main() {
CommonRegex find =newCommonRegex(text:''' John, please get that article on www.linkedin.com to me by 5:00PM on Jan 9th 2012. 4:00 would be ideal, actually. If you have any questions, you can reach my associate at (012)-345-6789 or associative@mail.com. I'll be on UK during the whole week on a J.R.R. Tolkien convention. ''');
print(find.dates);
print(find.times);
print(find.links);
print(find.emails);
print(find.acronyms);
}
Alternatively, you can generate a single CommonRegex instance and use it to parse multiple segments of text.
CommonRegex find =newCommonRegex();
print(find.getTimes (text:'The time is 1:00; 1 hour away: 2:00!'));
print(find.getPhones(text:'Give us a call: (555) 555-5555,'+' or 555-555-5555. If local: 555-5555'));
print(find.getIPv4 (text:'Valid IPs: 192.168.0.1;192.168.0.2;'+' Invalid IP: 267.277.234.234'));