Parse::Number::EN - Parse number from English text
This document describes version 0.07 of Parse::Number::EN (from Perl distribution Parse-Number-EN), released on 2016-06-14.
use Parse::Number::EN qw(parse_number_en $Pat); my @a = map {parse_number_en(text=>$_)} ("12,345.67", "-1.2e3", "x123", "1.23", "1,23"); # @a = (12345.67, -1200, undef, 1.23, 1) my @b = map {/^$Pat$/ ? 1:0} ("12,345.67", "-1.2e3", "x123", "1,23"); # @b = (1, 1, 0, 0)
The goal for this module is to parse/extract numbers written in some common notation in English text. That means, in addition to what Perl does, it also recognizes thousand separators (and fractions, percentages in the future).
None are exported by default, but they are exportable.
A regex for quickly matching/extracting number from text. It's not 100% perfect (the extracted number might not be valid), but it's simple and fast.
Parse number from English text.
This function can parse number with thousand separators (e.g. 10,000).
In the future percentage (e.g. 10.2%) and fractions (e.g. 1/3, 2 1/2) might also be supported.
This function is not exported by default, but exportable.
Arguments ('*' denotes required arguments):
text* => str
The input text that contains number.
Return value: (any)
This module uses a single regex and provides the regex for you to use. Other modules might be more accurate and/or faster. But this module is pretty fast.
Please visit the project's homepage at https://metacpan.org/release/Parse-Number-EN.
Source repository is at https://github.com/perlancar/perl-Parse-Number-EN.
Please report any bugs or feature requests on the bugtracker website https://rt.cpan.org/Public/Dist/Display.html?Name=Parse-Number-EN
When submitting a bug or request, please include a test-file or a patch to an existing test-file that illustrates the bug or desired feature.
Lingua::EN::Words2Nums
Other Parse::Number::* modules (for other languages).
perlancar <perlancar@cpan.org>
This software is copyright (c) 2016 by perlancar@cpan.org.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
To install Parse::Number::EN, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Parse::Number::EN
CPAN shell
perl -MCPAN -e shell install Parse::Number::EN
For more information on module installation, please visit the detailed CPAN module installation guide.