Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const duplicateCount = (text) => (text.match(/(w)(?=(?!.*1.*1).*1)/gi) || []).length;
- // (w)(?=(?!.*1.*1).*1)
- //
- // Options: Case insensitive; ^$ don’t match at line breaks
- //
- // Match the regex below and capture its match into backreference number 1 «(w)»
- // Match a single character that is a “word character” (ASCII letter, digit, or underscore only) «w»
- // Assert that the regex below can be matched starting at this position (positive lookahead) «(?=(?!.*1.*1).*1)»
- // Assert that it is impossible to match the regex below starting at this position (negative lookahead) «(?!.*1.*1)»
- // Match any single character that is NOT a line break character (line feed, carriage return, line separator, paragraph separator) «.*»
- // Between zero and unlimited times, as many times as possible, giving back as needed (greedy) «*»
- // 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»
- // Match any single character that is NOT a line break character (line feed, carriage return, line separator, paragraph separator) «.*»
- // Between zero and unlimited times, as many times as possible, giving back as needed (greedy) «*»
- // 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»
- // Match any single character that is NOT a line break character (line feed, carriage return, line separator, paragraph separator) «.*»
- // Between zero and unlimited times, as many times as possible, giving back as needed (greedy) «*»
- // 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