splitEntryValue

Splits a line into an entry and a value component.

This drop-in-replaces the regex: ^(?P<entry>[^ \t]+)[ \t]+(?P<value>.+).

@safe pure nothrow @nogc
splitEntryValue
(
const string line
)

Parameters

line string

String to split up.

Return Value

Type: auto

A Voldemort struct with an entry and a value member.

Examples

{
    immutable line = "monochrome            true";
    immutable result = splitEntryValue(line);
    assert((result.entry == "monochrome"), result.entry);
    assert((result.value == "true"), result.value);
}
{
    immutable line = "monochrome\tfalse";
    immutable result = splitEntryValue(line);
    assert((result.entry == "monochrome"), result.entry);
    assert((result.value == "false"), result.value);
}
{
    immutable line = "harbl                  ";
    immutable result = splitEntryValue(line);
    assert((result.entry == "harbl"), result.entry);
    assert(!result.value.length, result.value);
}
{
    immutable line = "ha\t \t \t\t  \t  \t      \tha";
    immutable result = splitEntryValue(line);
    assert((result.entry == "ha"), result.entry);
    assert((result.value == "ha"), result.value);
}
{
    immutable line = "#sendAfterConnect";
    immutable result = splitEntryValue(line);
    assert((result.entry == "#sendAfterConnect"), result.entry);
    assert(!result.value.length, result.value);
}