parseList

@safe nothrow
string[]
parseList
(
string value
)

Examples

it should parse an empty string

auto pieces = "".parseList;

pieces.should.equal([]);

it should not parse a string that does not contain []

auto pieces = "test".parseList;

pieces.should.equal([ "test" ]);

it should not parse a char that does not contain []

auto pieces = "t".parseList;

pieces.should.equal([ "t" ]);

it should parse an empty array

auto pieces = "[]".parseList;

pieces.should.equal([]);

it should parse a list of one number

auto pieces = "[1]".parseList;

pieces.should.equal(["1"]);

it should parse a list of two numbers

auto pieces = "[1,2]".parseList;

pieces.should.equal(["1","2"]);

it should remove the whitespaces from the parsed values

auto pieces = "[ 1, 2 ]".parseList;

pieces.should.equal(["1","2"]);

it should parse two string values that contain a ,

auto pieces = `[ "a,b", "c,d" ]`.parseList;

pieces.should.equal([`"a,b"`,`"c,d"`]);

it should parse two string values that contain a '

auto pieces = `[ "a'b", "c'd" ]`.parseList;

pieces.should.equal([`"a'b"`,`"c'd"`]);

it should parse two char values that contain a ,

auto pieces = `[ ',' , ',' ]`.parseList;

pieces.should.equal([`','`,`','`]);

it should parse two char values that contain [ and ]

auto pieces = `[ '[' , ']' ]`.parseList;

pieces.should.equal([`'['`,`']'`]);

it should parse two string values that contain [ and ]

auto pieces = `[ "[" , "]" ]`.parseList;

pieces.should.equal([`"["`,`"]"`]);

it should parse two char values that contain a "

auto pieces = `[ '"' , '"' ]`.parseList;

pieces.should.equal([`'"'`,`'"'`]);

it should parse two empty lists

auto pieces = `[ [] , [] ]`.parseList;
pieces.should.equal([`[]`,`[]`]);

it should parse two nested lists

auto pieces = `[ [[],[]] , [[[]],[]] ]`.parseList;
pieces.should.equal([`[[],[]]`,`[[[]],[]]`]);

it should parse two lists with items

auto pieces = `[ [1,2] , [3,4] ]`.parseList;
pieces.should.equal([`[1,2]`,`[3,4]`]);

it should parse two lists with string and char items

auto pieces = `[ ["1", "2"] , ['3', '4'] ]`.parseList;
pieces.should.equal([`["1", "2"]`,`['3', '4']`]);

it should parse two lists with string and char items

auto pieces = `[ ["1", "2"] , ['3', '4'] ]`.parseList;
pieces.should.equal([`["1", "2"]`,`['3', '4']`]);

Meta