Advertisement
rbrtryn

Regex Groups

Mar 9th, 2021 (edited)
457
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.80 KB | None | 0 0
  1. Regex Groups
  2.  
  3. Abort Existing Task
  4.  
  5. <%par(1) is the string to be searched
  6. %par(2) is the regular expression>
  7. A1: Anchor
  8.  
  9. A2: Java Function
  10. Return: pattern
  11. Class Or Object: Pattern
  12. Function: compile
  13. {Pattern} (String)
  14. Param: "%par(2)"
  15. Continue Task After Error: On
  16.  
  17. A3: If %err Set
  18.  
  19. A4: Flash
  20. Text: Regex compile error: Invalid expression
  21. Long: On
  22.  
  23. A5: Stop
  24. With Error: Off
  25.  
  26. A6: End If
  27.  
  28. A7: Java Function
  29. Return: matcher
  30. Class Or Object: pattern
  31. Function: matcher
  32. {Matcher} (CharSequence)
  33. Param: "%par(1)"
  34.  
  35. A8: Java Function
  36. Return: %rg_success
  37. Class Or Object: matcher
  38. Function: find
  39. {boolean} ()
  40.  
  41. A9: Return
  42. Stop: On
  43. Local Variable Passthrough: On
  44. Replace On Passthrough: Off
  45. If %rg_success ~ false
  46.  
  47. A10: Java Function
  48. Return: %rg_match
  49. Class Or Object: matcher
  50. Function: group
  51. {String} ()
  52.  
  53. A11: Java Function
  54. Return: %rg_group_count
  55. Class Or Object: matcher
  56. Function: groupCount
  57. {int} ()
  58.  
  59. A12: Return
  60. Stop: On
  61. Local Variable Passthrough: On
  62. Replace On Passthrough: Off
  63. If %rg_group_count = 0
  64.  
  65. A13: For
  66. Variable: %index
  67. Items: 1:%rg_group_count
  68.  
  69. A14: Java Function
  70. Return: %rg_group(%index)
  71. Class Or Object: matcher
  72. Function: group
  73. {String} (int)
  74. Param: %index
  75.  
  76. A15: End For
  77.  
  78. A16: Return
  79. Stop: On
  80. Local Variable Passthrough: On
  81. Replace On Passthrough: Off
  82. If %SDK < 26
  83.  
  84. <Extract the names of named groups, if any>
  85. A17: Variable Search Replace
  86. Variable: %par(2)
  87. Search: (?<=\(\?\<)\w+
  88. Ignore Case: Off
  89. Multi-Line: Off
  90. One Match Only: Off
  91. Store Matches In Array: %rg_name
  92. Replace Matches: Off
  93.  
  94. A18: For
  95. Variable: %name
  96. Items: %rg_name()
  97.  
  98. A19: Java Function
  99. Return: %%name
  100. Class Or Object: matcher
  101. Function: group
  102. {String} (String)
  103. Param: %name
  104.  
  105. A20: End For
  106.  
  107. A21: Array Clear
  108. Variable Array: %rg_name
  109.  
  110. A22: Return
  111. Stop: On
  112. Local Variable Passthrough: On
  113. Replace On Passthrough: Off
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement