I have a text file that consist of string. What i want to do is to separate the string with "[ham]" and the string with "[spam]" inside to the different array, how can i do that, i think about to use regex to recognize the pattern (ham & spam), but i have no idea to start. please help me.
String in text file:
good [ham]
very good [ham]
bad [spam]
very bad [spam]
very bad, very bad [spam]
and i want the output to be like this:
Ham array:
good
very good
Spam array:
bad
very bad
very bad, very bad
Help me please.