Delphi Split(): retrieve the separator into separators list -


i want retrieve (at runtime) separator split string, eg.:

astr := 'foo=bar'; aparts := astr.split(['=', '!', '<', '>', '^']); 

aparts[0] foo, aparts[1] bar, separator? there way retrieve char used split string: =?

i think need parse delimiters separately. instance, following code put delimiters second array named separators.

var   astr: string;   aparts: system.tarray<system.string>;   separators: system.tarray<system.string>;   findindex: integer;   findpos: integer; begin   astr := 'foo=bar!abc^def';   aparts := astr.split(['=', '!', '<', '>', '^']);   findindex := 1;   repeat     findpos := astr.indexofany(['=', '!', '<', '>', '^'], findindex);     if findpos >= 1     begin       setlength(separators, length(separators) + 1);       separators[length(separators) - 1] := astr.substring(findpos, 1);     end;     findindex := findpos + 1;   until findpos = -1; end; 

Comments

Popular posts from this blog

php - Vagrant up error - Uncaught Reflection Exception: Class DOMDocument does not exist -

vue.js - Create hooks for automated testing -

Add new key value to json node in java -