I have the following Regex
console.log("Test #words 100-200-300".toLowerCase().match(/(?:\B#)?\w+/g))
From the above you can see it is splitting "100-200-300". I want it to ignore "-" and keep the word in full as below:
--> ["test", "#words", "100-200-300"]
I need the Regex to keep the same rules, with the addition of not splitting words connected with "-"
-and\w+like(?:\B#)?\w+(?:-\w+)*or without the\Blike#?\w+(?:-\w+)*regex101.com/r/YRg5My/1spliton a space character:str.split(" ")? What do you do in case ofwords_separated_by_underscores?.toLowerCase()as\walso matches that. Tryconsole.log("Test #words 100-200-300".match(/#?\w+(?:-\w+)*/g));See rextester.com/RSVR49477