example.k 602 B

1234567891011121314151617181920212223242526
  1. \d re
  2. \l re.k
  3. \d .
  4. para:`0:
  5. para"regex: ", rex:"[\\+-]?[0-9]+(\\.[0-9]+)?([Ee][\\+-]?[0-9]+)?"
  6. rx:re.match[re.cmp@rex]
  7. {para"match: ",x;`0:$rx x}'("1";"-3.1415e0";"-.1415e0";"-3.1415e";"dog");
  8. cases:("abc";"xxxabbc";"abbbcyyy";"xxxabbbbcyyy")
  9. testcases:{para"search ",z;`0:$x z;para"match ",z;`0:$y z}
  10. test:{para"---";para"regex: ", x;testcases[re.match[re.scmp@x];re.match[re.cmp@x]]'y;}
  11. test["ab+c";cases]
  12. test["^ab+c";cases]
  13. test["ab+c$";cases]
  14. test["^ab+c$";cases]
  15. /
  16. / [[https://github.com/gitonthescene/ngnk-libs/tree/master/trees]]
  17. \d tree
  18. \l trees.k
  19. \d .
  20. (e;t):re.prs rex
  21. tree.shw[`k'e;t]