Skip to content

Add optional spacer for parser #5

@sitch

Description

@sitch

Was parsing output from dstat and you see values like:

504k   11k
1189B 2733B
59k   14k
14M 8959B 

Which fails parsing due to the mandatory single spacer " " in the regex between the value and unit

i.e.:

iex> FileSize.parse("1GB") 
{:error, %FileSize.ParseError{reason: :format, value: "1GB"}}

whereas if the space is there it works

iex> FileSize.parse("1 GB") 
{:ok, #FileSize<"1 GB">}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions