javascript - Why can't '\b\w+(?=ing)\b' match "I'm singing while you're dancing" -
i have following regex
var reg = /\b\w+(?=ing)\b/g; var str = "i'm singing while you're dancing"; str.match(reg) // ==>null but if regex /\b\w+(?=ing\b)/g str can match 'sing,danc'
why mach previous example doesn't?
you need remove \b @ end since part want match not end on boundary . danc , sing batch \b\w+\b dancing , singing not
\b\w+(?=ing) check demo here
\b\w+(?=ing\b) would make sure ing @ boundary , not
\w+ part
Comments
Post a Comment