Advertisement
Guest User

Untitled

a guest
Jun 17th, 2019
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.86 KB | None | 0 0
  1. const duplicateCount = (text) => (text.match(/(w)(?=(?!.*1.*1).*1)/gi) || []).length;
  2.  
  3. // (w)(?=(?!.*1.*1).*1)
  4. //
  5. // Options: Case insensitive; ^$ don’t match at line breaks
  6. //
  7. // Match the regex below and capture its match into backreference number 1 «(w)»
  8. // Match a single character that is a “word character” (ASCII letter, digit, or underscore only) «w»
  9. // Assert that the regex below can be matched starting at this position (positive lookahead) «(?=(?!.*1.*1).*1)»
  10. // Assert that it is impossible to match the regex below starting at this position (negative lookahead) «(?!.*1.*1)»
  11. // Match any single character that is NOT a line break character (line feed, carriage return, line separator, paragraph separator) «.*»
  12. // Between zero and unlimited times, as many times as possible, giving back as needed (greedy) «*»
  13. // Match the same text that was most recently matched by capturing group number 1 (case insensitive; ignore if the group did not participate in the match so far) «1»
  14. // Match any single character that is NOT a line break character (line feed, carriage return, line separator, paragraph separator) «.*»
  15. // Between zero and unlimited times, as many times as possible, giving back as needed (greedy) «*»
  16. // Match the same text that was most recently matched by capturing group number 1 (case insensitive; ignore if the group did not participate in the match so far) «1»
  17. // Match any single character that is NOT a line break character (line feed, carriage return, line separator, paragraph separator) «.*»
  18. // Between zero and unlimited times, as many times as possible, giving back as needed (greedy) «*»
  19. // Match the same text that was most recently matched by capturing group number 1 (case insensitive; ignore if the group did not participate in the match so far) «1»
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement