I have a crazy string, something like:
sun #plants #!wood% ##arebaba#tey travel#blessed #weed das#$#F!@D!AAAA
I want to extract all \"
Just using match you could get all the group 1 matches into an array.
(?:^|[ #]+)([^ #]+)(?=[ #]|$)
Easy!
(?: ^ | [ #]+ )
( [^ #]+ ) # (1)
(?= [ #] | $ )
Or, if you feel it's this simple, then just use ([^ #]+)
or [^ #]+
which gets the same thing (like split in reverse).
You can use match
using regex: [^#\s]+
:
var str = 'sun #plants #!wood% ##arebaba#tey travel#blessed #weed das#$#F!@D!AAAA';
var arr = str.match(/[^\s#]+/g);
console.log(arr);
RegEx Demo