So I have a set of data that can look like this (sample line-by-line):
verkoop
verkoop [Hot News]
verkoop [Hot News] [Smurf]
verkoop test
verkoop test [Hot News]
verkoop test [Hot News] [Smurf]
what I want is for all the text (in this example it can be either verkoop or verkoop test) and all the tags (example: [Hot News] or [Hot News] [Smurf]) to be separated (in groups preferrably but eventually I just need these in an array in C#).
The text can remain 1 group but each tag must form it’s own group.
I’ve tried to mess around with a regular expression but can’t seem to be able to make it work with more than 1 tag (for example [Hot News] [Smurf]).
This is what I came up with:
^([a-zA-Z0-9\s]*)\s?(((?:[\[]{1}[a-zA-Z\s]+[\]]{1}\s?)*))$
Any help is greatly appreciated!
If the tags are always at the end of the string, you could simply split on the first occurrence of
[, if it exists.which prints: