2
0

Rex.hx 3.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. /*
  2. * Copyright (C)2005-2019 Haxe Foundation
  3. *
  4. * Permission is hereby granted, free of charge, to any person obtaining a
  5. * copy of this software and associated documentation files (the "Software"),
  6. * to deal in the Software without restriction, including without limitation
  7. * the rights to use, copy, modify, merge, publish, distribute, sublicense,
  8. * and/or sell copies of the Software, and to permit persons to whom the
  9. * Software is furnished to do so, subject to the following conditions:
  10. *
  11. * The above copyright notice and this permission notice shall be included in
  12. * all copies or substantial portions of the Software.
  13. *
  14. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  15. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  16. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  17. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  18. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  19. * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
  20. * DEALINGS IN THE SOFTWARE.
  21. */
  22. package lua.lib.lrexlib;
  23. import haxe.extern.EitherType;
  24. @:luaRequire("rex_pcre")
  25. extern class Rex {
  26. inline static function create(expr:String, flag:EitherType<Int, String>):Rex {
  27. return untyped Rex['new'](expr, flag);
  28. }
  29. /**
  30. The function searches for the first match of the regexp `patt` in the
  31. string `subj`, starting from offset `init`, subject to flags `cf` and `ef`.
  32. @return matched string, or array of strings.
  33. **/
  34. static function match(patt:EitherType<Rex, String>, subj:String, ?init:Int, ?ef:Int):Dynamic;
  35. /**
  36. The function searches for the first match of the regexp patt in the string
  37. `subj`, starting from offset `init`, subject to flags `cf` and `ef`.
  38. **/
  39. static function find(patt:EitherType<Rex, String>, subj:String, ?init:Int, ?ef:Int):Dynamic;
  40. /**
  41. The function is intended for use in the generic for Lua construct. It is
  42. used for splitting a subject string `subj` into parts (sections). The `sep`
  43. parameter is a regular expression pattern representing separators between
  44. the sections.
  45. **/
  46. static function split(subj:String, sep:EitherType<Rex, String>, ?cf:Int, ?ef:Int):Void->String;
  47. /**
  48. This function counts matches of the pattern `patt` in the string `subj`.
  49. **/
  50. static function count(subj:String, patt:EitherType<Rex, String>, cf:Int, ef:Int):Dynamic;
  51. static function flags(?tb:Dynamic):Dynamic;
  52. /**
  53. The function searches for the first match of the regexp in the string
  54. `subj`, starting from offset `init`, subject to execution flags `ef`.
  55. **/
  56. function tfind(subj:String, ?init:Int, ?ef:Int):Dynamic;
  57. /**
  58. This function searches for the first match of the regexp in the string
  59. `subj`, starting from offset `init`, subject to execution flags `ef`.
  60. **/
  61. function exec(subj:String, ?init:Int, ?ef:Int):Dynamic;
  62. /**
  63. The function is intended for use in the generic for Lua construct. It
  64. returns an iterator for repeated matching of the pattern patt in the
  65. string `subj`, subject to flags `cf` and `ef`.
  66. **/
  67. static function gmatch(subj:String, patt:EitherType<Rex, String>, ?cf:Int, ?ef:Int):Void->String;
  68. /**
  69. This function searches for all matches of the pattern `patt` in the string
  70. `subj` and replaces them according to the parameters `repl` and `n`.
  71. **/
  72. static function gsub(subj:String, patt:EitherType<Rex, String>, repl:Dynamic, ?n:Int, ?cf:Int, ?ef:Int):String;
  73. }