SoftBank.Cldr.Number.scan
You're seeing just the function
scan
, go back to SoftBank.Cldr.Number module for more information.
Scans a string locale-aware manner and returns a list of strings and numbers.
Arguments
string
is anyString.t
options
is a keyword list of options
Options
:number
is one of:integer
,:float
,:decimal
ornil
. The default isnil
meaning that the type auto-detected as either aninteger
or afloat
.:locale
is any locale returned byCldr.known_locale_names/1
or aCldr.LanguageTag.t
. The default isSoftBank.Cldr.get_locale/0
.
Returns
- A list of strings and numbers
Notes
Number parsing is performed by Cldr.Number.Parser.parse/2
and any options provided are passed to that function.
Examples
iex> SoftBank.Cldr.Number.scan("£1_000_000.34")
["£", 1000000.34]
iex> SoftBank.Cldr.Number.scan("I want £1_000_000 dollars")
["I want £", 1000000, " dollars"]
iex> SoftBank.Cldr.Number.scan("The prize is 23")
["The prize is ", 23]
iex> SoftBank.Cldr.Number.scan("The lottery number is 23 for the next draw")
["The lottery number is ", 23, " for the next draw"]
iex> SoftBank.Cldr.Number.scan("The loss is -1.000 euros", locale: "de", number: :integer)
["The loss is ", -1000, " euros"]