Methods
-
cardinal()
-
Returns a parser that will parse english cardinal numbers into their numerical counterparts.
Example
parse(cardinal(), "two thousand"); // => 2000
-
integer(base)
-
Returns a parser that matches an integer, with an optional + or - sign.
Parameters:
Name Type Argument Default Description base
Integer <optional>
10 Base to use when parsing the integer.
Example
parse(integer(), "-1234"); // => -1234
-
natural(base)
-
Returns a parser that matches a natural number. That is, a number without a positive/negative sign or decimal places, and returns a positive integer.
Parameters:
Name Type Argument Default Description base
Integer <optional>
10 Base to use when parsing the number.
Example
parse(natural(), "1234"); // => 1234
-
ordinal()
-
Returns a parser that will parse english ordinal numbers into their numerical counterparts.
Example
parse(ordinal(), "one-hundred thousand and fifth"); // 100005
-
real()
-
Returns a parser that will parse floating point numbers.
Example
parse(real(), "-1234e-10"); // => -1.234e-7
-
shortOrdinal(strict)
-
Returns a parser that will parse shorthand english ordinal numbers into their numerical counterparts.
Parameters:
Name Type Argument Default Description strict
Boolean <optional>
true Whether to accept only appropriate suffixes for each number. (if false,
2th
parses to2
)Example
parse(shortOrdinal(), "5th"); // 5