I have this simple code:
let arr = [
  'bill-items',
  'bills',
  'customer-return-items',
  'customer-returns'
]
let re = new RegExp('^b*')
arr.forEach((e) => {
  console.log(`Matching ${e}: ` + re.test(e))
})I expect two matches and two non-matches. Strangely I get four matches! Check here: https://jsfiddle.net/kargirwar/gu7Lshnt/9/
What is happening?
 
     
     
    