项目作者: bluelovers

项目描述 :
check RegExp ( regular expressions ) support
高级语言: TypeScript
项目地址: git://github.com/bluelovers/regexp-support.git
创建时间: 2018-04-26T07:46:38Z
项目社区:https://github.com/bluelovers/regexp-support

开源协议:

下载


regexp-support

  1. check RegExp ( regular expressions ) support

install

  1. npm install regexp-support

version test log

Api

allow u check support on other RegExp base class

  1. hasSupportFlag(flag: string, RegExpClass?: typeof RegExp, skipPatternCheck?: boolean): boolean
  2. testFlag(flag: string, RegExpClass?: typeof RegExp, flagsPattern?): boolean

RegExpClass can be Object with create, for some class can’t create by new

  1. export interface ICreateRegExp
  2. {
  3. create(pattern: string, flag?: string, ...argv)
  4. }

demo

  1. import support from 'regexp-support';
  2. console.log(support);

todo

desc

lookAheadPositive, lookAheadNegative

  • aa(?=bb)
  • aa(?!bb)

lookBehindPositive

  • (?<=\$)foo
  1. const RE_DOLLAR_PREFIX = /(?<=\$)foo/g;
  2. '$foo %foo foo'.replace(RE_DOLLAR_PREFIX, 'bar'); // => '$bar %foo foo'

lookBehindNegative

  • (?<!\$)foo
  1. const RE_NO_DOLLAR_PREFIX = /(?<!\$)foo/g;
  2. '$foo %foo foo'.replace(RE_NO_DOLLAR_PREFIX, 'bar'); // => '$foo %bar bar'

node.js 10

  1. { nativeFlags: 'gimsuy',
  2. flags:
  3. { multiline: true,
  4. m: true,
  5. global: true,
  6. g: true,
  7. ignoreCase: true,
  8. i: true,
  9. sticky: true,
  10. y: true,
  11. unicode: true,
  12. u: true,
  13. dotAll: true,
  14. s: true,
  15. freeSpacing: false,
  16. x: false,
  17. n: false },
  18. flagsAll: { g: true, i: true, m: true, s: true, u: true, y: true },
  19. pattern:
  20. { namedCapturingGroups: true,
  21. namedCapturingGroupsUnicode: true,
  22. namedCapturingGroupsEmoji: false,
  23. namedCapturingGroupsBackreference: true,
  24. namedCapturingGroupsDuplicate: false,
  25. lookAheadPositive: true,
  26. lookAheadNegative: true,
  27. lookBehindPositive: true,
  28. lookBehindNegative: true,
  29. dotUnicodeEmoji: true,
  30. classSub: false },
  31. prototype:
  32. { source: true,
  33. flags: true,
  34. lastIndex: true,
  35. dotAll: true,
  36. global: true,
  37. ignoreCase: true,
  38. multiline: true,
  39. sticky: true,
  40. unicode: true },
  41. static:
  42. { '$1': true,
  43. '$2': true,
  44. '$3': true,
  45. '$4': true,
  46. '$5': true,
  47. '$6': true,
  48. '$7': true,
  49. '$8': true,
  50. '$9': true,
  51. input: true,
  52. '$_': true,
  53. lastMatch: true,
  54. '$&': true,
  55. lastParen: true,
  56. '$+': true,
  57. leftContext: true,
  58. '$`': true,
  59. rightContext: true,
  60. '$\'': true,
  61. '$10': false,
  62. '$100': false },
  63. symbol:
  64. { species: false,
  65. match: true,
  66. replace: true,
  67. search: true,
  68. split: true },
  69. objectStringTag: '[object RegExp]',
  70. unicodeSet:
  71. { unicode: true,
  72. script: true,
  73. blocks: false,
  74. unicodeTest:
  75. { C: true,
  76. Other: true,
  77. Cc: true,
  78. Control: true,
  79. Cs: true,
  80. Surrogate: true,
  81. L: true,
  82. Letter: true,
  83. LC: true,
  84. Cased_Letter: true,
  85. Ll: true,
  86. Lowercase_Letter: true,
  87. Lo: true,
  88. Other_Letter: true,
  89. Lu: true,
  90. Uppercase_Letter: true,
  91. M: true,
  92. Mark: true,
  93. Me: true,
  94. Enclosing_Mark: true,
  95. Mn: true,
  96. Nonspacing_Mark: true,
  97. N: true,
  98. Number: true,
  99. Nd: true,
  100. Decimal_Number: true,
  101. Nl: true,
  102. Letter_Number: true,
  103. No: true,
  104. Other_Number: true,
  105. P: true,
  106. Punctuation: true,
  107. Pc: true,
  108. Connector_Punctuation: true,
  109. Pd: true,
  110. Dash_Punctuation: true,
  111. Pe: true,
  112. Close_Punctuation: true,
  113. Pf: true,
  114. Final_Punctuation: true,
  115. Pi: true,
  116. Initial_Punctuation: true,
  117. Po: true,
  118. Other_Punctuation: true,
  119. Ps: true,
  120. Open_Punctuation: true,
  121. S: true,
  122. Symbol: true,
  123. Sc: true,
  124. Currency_Symbol: true,
  125. Sk: true,
  126. Modifier_Symbol: true,
  127. Sm: true,
  128. Math_Symbol: true,
  129. So: true,
  130. Other_Symbol: true,
  131. Z: true,
  132. Separator: true,
  133. Zl: true,
  134. Line_Separator: true,
  135. Zp: true,
  136. Paragraph_Separator: true,
  137. Zs: true,
  138. Space_Separator: true,
  139. ASCII: true,
  140. Alphabetic: true,
  141. Any: true,
  142. White_Space: true,
  143. Alpha: true,
  144. Emoji: true,
  145. Emoji_Component: true,
  146. Emoji_Modifier: true,
  147. Emoji_Presentation: true,
  148. Ideographic: true,
  149. Ideo: true,
  150. Lower: true,
  151. Quotation_Mark: true,
  152. QMark: true,
  153. Unified_Ideograph: true,
  154. Upper: true,
  155. Combining_Mark: true,
  156. punct: true,
  157. Digit: false,
  158. Alnum: false,
  159. Punct: false,
  160. Graph: false,
  161. Blank: false,
  162. Cntrl: false,
  163. XDigit: false,
  164. Space: false,
  165. Decimal_Digit_Number: false },
  166. scriptTest:
  167. { Arabic: true,
  168. Bengali: true,
  169. Common: true,
  170. Coptic: true,
  171. Cyrillic: true,
  172. Ethiopic: true,
  173. Georgian: true,
  174. Greek: true,
  175. Han: true,
  176. Hangul: true,
  177. Hiragana: true,
  178. Katakana: true,
  179. Latin: true,
  180. Tamil: true,
  181. Tibetan: true,
  182. Arab: true,
  183. Beng: true,
  184. Copt: true,
  185. Cyrl: true,
  186. Ethi: true,
  187. Geor: true,
  188. Grek: true,
  189. Hani: true,
  190. Hira: true,
  191. Kana: true,
  192. Latn: true,
  193. Taml: true,
  194. Tibt: true },
  195. blocksTest: { InBasic_Latin: false } } }

node.js 9

by test on RunKit

  1. { flags:
  2. { multiline: true,
  3. m: true,
  4. global: true,
  5. g: true,
  6. ignoreCase: true,
  7. i: true,
  8. sticky: true,
  9. y: true,
  10. unicode: true,
  11. u: true,
  12. dotAll: true,
  13. s: true,
  14. freeSpacing: false,
  15. x: false,
  16. n: false },
  17. flagsAll: { g: true, i: true, m: true, s: true, u: true, y: true },
  18. pattern:
  19. { namedCapturingGroups: false,
  20. namedCapturingGroupsUnicode: false,
  21. namedCapturingGroupsEmoji: false } }

node.js 8

by test on RunKit

  1. { flags:
  2. { multiline: true,
  3. m: true,
  4. global: true,
  5. g: true,
  6. ignoreCase: true,
  7. i: true,
  8. sticky: true,
  9. y: true,
  10. unicode: true,
  11. u: true,
  12. dotAll: true,
  13. s: true,
  14. freeSpacing: false,
  15. x: false,
  16. n: false },
  17. flagsAll: { g: true, i: true, m: true, s: true, u: true, y: true },
  18. pattern:
  19. { namedCapturingGroups: false,
  20. namedCapturingGroupsUnicode: false,
  21. namedCapturingGroupsEmoji: false } }