Top Prev Next Up Down TEST

ExYpsilon

Example of splitting a row with text


001| with Ada.Text_IO;
002| with Y2018.Text.Core; use Y2018.Text.Core;
003| with Y2018.Text.Core.Str; use Y2018.Text.Core.Str;
004| with Y2018.Text.Core.CVarPack; use Y2018.Text.Core.CVarPack;
005| with Y2018.Text.Jets; use Y2018.Text.Jets;
006| with Y2018.Text.Jets.MatchPack;
007| with Y2018.Text.Jets.PatternPack;
008| --with DSECT;
009| procedure ExYpsilon is
010| __p:PatternPack.Pattern_AC:=PatternPack.compileM("^(.*?),[\\s]*"c);
011| __m : MatchPack.Match_TY;
012| __line:CFix:="Huey, Dewey, Louie, Duck"c;
013| __startPos:Integer:=1;
014| __nextPos:Integer;
015| begin
016| __while startPos <= line'length loop
017| _____if PatternPack.matches(p,startPos,nextPos,line,m) then
018| ________declare
019| ___________r:I_A_ARRAY:=MatchPack.getMatch(m);
020| ________begin
021| ___________Ada.Text_IO.Put_Line("> " & subIA(line,r(1)));
022| ________end;
023| ________startPos:=nextPos;
024| _____else
025| ________Ada.Text_IO.Put_Line("> " & subC(line,startPos));
026| ________exit;
027| _____end if;
028| __end loop;
029| __Ada.Text_IO.Put_Line ("*** End of ExYpsilon ***");
030| end ExYpsilon;


Note line 010, pattern 'p' is initiated with a compiled result of the pattern.

Result

Running export LD_LIBRARY_PATH=lib;bin/exypsilon in TEST directory.


001| > Huey
002| > Dewey
003| > Louie
004| > Duck
005| *** End of ExYpsilon ***