MyApp.Cldr.Number.scan

You're seeing just the function scan, go back to MyApp.Cldr.Number module for more information.
Link to this function

scan(string, options \\ [])

View Source

Scans a string locale-aware manner and returns a list of strings and numbers.

Arguments

  • string is any String.t

  • options is a keyword list of options

Options

  • :number is one of :integer, :float, :decimal or nil. The default is nil meaning that the type auto-detected as either an integer or a float.

  • :locale is any locale returned by Cldr.known_locale_names/1 or a Cldr.LanguageTag.t. The default is MyApp.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> MyApp.Cldr.Number.scan("£1_000_000.34")
["£", 1000000.34]

iex> MyApp.Cldr.Number.scan("I want £1_000_000 dollars")
["I want £", 1000000, " dollars"]

iex> MyApp.Cldr.Number.scan("The prize is 23")
["The prize is ", 23]

iex> MyApp.Cldr.Number.scan("The lottery number is 23 for the next draw")
["The lottery number is ", 23, " for the next draw"]

iex> MyApp.Cldr.Number.scan("The loss is -1.000 euros", locale: "de", number: :integer)
["The loss is ", -1000, " euros"]