Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- (?<= # Positive look-behind
- b # Word boundary
- | # Or
- _ # Underscore
- ) # End group
- d # Digit
- (?= # Positive look-ahead
- b|_) # Word boundary or underscore
- const manualBoundaries = /d/g
- const matches = [];
- while ((match = manualBoundaries.exec(str)) !== null) {
- const m = match[0]
- const i = match.index
- if ((i == 0 || str[i - 1].match(/(W|_)/)) &&
- (i + m.length == str.length || str[i + m.length].match(/(W|_)/)))
- matches.push(m)
- }
- const matches = [];
- str.replace(manualBoundaries, (m, i) => {
- if ((i == 0 || str[i - 1].match(/(W|_)/)) &&
- (i + m.length == str.length || str[i + m.length].match(/(W|_)/)))
- matches.push(m);
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement