Rex.hx 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. package lua.lib.lrexlib;
  2. @:luaRequire("rex_pcre")
  3. extern class Rex {
  4. @:overload( function (expr : String, flag : Int) : Rex{})
  5. inline public static function create(expr : String, flag : String) : Rex{
  6. return untyped Rex['new'](expr, flag);
  7. }
  8. /**
  9. The function searches for the first match of the regexp `patt` in the
  10. string `subj`, starting from offset `init`, subject to flags `cf` and `ef`.
  11. @return matched string, or array of strings.
  12. **/
  13. public static function match(patt : String, ?init : Int, ?ef : Int) : Dynamic;
  14. /**
  15. The function searches for the first match of the regexp patt in the string
  16. `subj`, starting from offset `init`, subject to flags `cf` and `ef`.
  17. **/
  18. public static function find(subj : String, ?init : Int, ?ef : Int) : Dynamic;
  19. /**
  20. The function is intended for use in the generic for Lua construct. It is
  21. used for splitting a subject string `subj` into parts (sections). The `sep`
  22. parameter is a regular expression pattern representing separators between
  23. the sections.
  24. **/
  25. @:overload( function (subj : String, sep : Rex, ?cf : Int, ?ef : Int) : Void->String{})
  26. public static function split(subj : String, sep : String, ?cf : Int, ?ef : Int) : Void->String;
  27. /**
  28. This function counts matches of the pattern `patt` in the string `subj`.
  29. **/
  30. public static function count(subj : String, patt : String, cf : Int, ef : Int) : Dynamic;
  31. public static function flags(?tb:Dynamic) : Dynamic;
  32. /**
  33. The function searches for the first match of the regexp in the string
  34. `subj`, starting from offset `init`, subject to execution flags `ef`.
  35. **/
  36. public function tfind(subj : String, ?init : Int, ?ef : Int) : Dynamic;
  37. /**
  38. This function searches for the first match of the regexp in the string
  39. `subj`, starting from offset `init`, subject to execution flags `ef`.
  40. **/
  41. public function exec(subj : String, ?init : Int, ?ef : Int) : Dynamic;
  42. /**
  43. The function is intended for use in the generic for Lua construct. It
  44. returns an iterator for repeated matching of the pattern patt in the
  45. string `subj`, subject to flags `cf` and `ef`.
  46. **/
  47. public static function gmatch(subj : String, ?cf : Int, ?ef : Int) : Dynamic; // TODO: Extern a lua iterator
  48. /**
  49. This function searches for all matches of the pattern `patt` in the string
  50. `subj` and replaces them according to the parameters `repl` and `n`.
  51. **/
  52. @:overload( function (subj : String, patt : Rex, repl: Dynamic, ?n: Int, ?cf : Int, ?ef : Int) : String {})
  53. public static function gsub(subj : String, patt : String, repl: Dynamic, ?n: Int, ?cf : Int, ?ef : Int) : String;
  54. }