This is a port of CommonRegex by Author Madison May (https://github.com/madisonmay)
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.
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'
main() { CommonRegex find = new CommonRegex(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); }
returns:
[Jan 9th 2012]
[5:00, 4:00]
[www.linkedin.com]
[associative@mail.com]
[UK, J.R.R.]
Alternatively, you can generate a single CommonRegex instance and use it to parse multiple segments of text.
CommonRegex find = new CommonRegex(); 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'));
returns:
[1:00, 2:00]
[(555) 555-5555, 555-555-5555, 555-5555]
[192.168.0.1, 192.168.0.2]
Please note that this library is currently English/US specific.
Supported Methods/AttributesCommonRegex for Python (https://github.com/madisonmay/CommonRegex)
CommonRegexJS (https://github.com/talyssonoc/CommonRegexJS)
CommonRegexScala (https://github.com/everpeace/CommonRegexScala)
CommonRegexJava (https://github.com/talyssonoc/CommonRegexJava)
CommonRegexCobra (https://github.com/PurityLake/CommonRegex-Cobra)
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4