The regex:
"12 DOse Flaschentomaten".split(/(\d+(?:\s(?:Dose|TL|EL)){0,})\s+(.*)/gi)
Gives me in the regex tool (https://www.regex101.com/) two groups:
12 DOse
Flaschentomaten
Which is what I want.
But in the javascript console this array
["", "12 DOse", "Flaschentomaten", ""]
Side Questions: If I want to use an external array for the filter words do I have to define it as a string: var filterWords = "sp, ts, spoon"; Can I use the i tag for not case sensitive also only on groups?
array.shift()andarray.pop()afterwards but why does it add the empty strings in the first place/ and how to avoid that?