This isn't so much about how to achieve what is explained in the example, there are plenty of easy ways to do it. The question is WHY does the example not behave as expected?
1. If I have the following string
"#foo#bar"
2. And I'm trying to get [foo, bar]
with the following regex in JavaScript
"#foo#bar".match(/(?:#)([a-zA-Z]*)/gi)
3. It returns
Array [ "#foo", "#bar" ]
Ignoring the non-capturing group (?:#)
It works as I first expected in here https://regex101.com/r/zI0wH9/1
So why is this? Do JS regexes behave somehow differently?