Regex.hx 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. /*
  2. * Copyright (C)2005-2012 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 cs.system.text.regularExpressions;
  23. import cs.NativeArray;
  24. @:native('System.Text.RegularExpressions.Regex') extern class Regex
  25. {
  26. function new(pattern:String, options:RegexOptions):Void;
  27. @:overload(function(input:String, startPos:Int, len:Int):Match{})
  28. @:overload(function(input:String, startPos:Int):Match{})
  29. function Match(input:String):Match;
  30. function Split(input:String):NativeArray<String>;
  31. @:overload(function(input:String, replacement:String,max:Int):String{})
  32. function Replace(input:String, replacement:String):String;
  33. }
  34. @:native("System.Text.RegularExpressions.RegexOptions") extern enum RegexOptions
  35. {
  36. None;
  37. IgnoreCase;
  38. Multiline;
  39. ExplicitCapture;
  40. Compiled;
  41. Singleline;
  42. IgnorePatternWhitespace;
  43. RightToLeft;
  44. ECMAScript;
  45. CultureInvariant;
  46. }
  47. @:native("System.Text.RegularExpressions.Capture") extern class Capture
  48. {
  49. var Index(default, null):Int;
  50. var Length(default, null):Int;
  51. var Value(default, null):String;
  52. }
  53. @:native("System.Text.RegularExpressions.Group") extern class Group extends Capture
  54. {
  55. var Success(default, null):Bool;
  56. }
  57. @:native("System.Text.RegularExpressions.Match") extern class Match extends Group
  58. {
  59. var Captures(default, null):CaptureCollection;
  60. var Groups(default, null):GroupCollection;
  61. }
  62. @:native("System.Text.RegularExpressions.CaptureCollection") extern class CaptureCollection implements ArrayAccess<Capture>
  63. {
  64. var Count(default, null):Int;
  65. }
  66. @:native("System.Text.RegularExpressions.GroupCollection") extern class GroupCollection implements ArrayAccess<Group>
  67. {
  68. var Count(default, null):Int;
  69. }