I m having a string as below
This is a test\nAnother test\n#art\n#paintings#collections
From which i have pick the words - art, paintings,collections.
I have written a java program for that here. The code -
String str = "This is a test\nAnother test\n#art\n#paintings#collections";
String tag_name ="";
String[] sp = str.split(" |\n");
for (int j =0; j<sp.length; j++) {
//System.out.println(""+sp[j]);
if ( String.valueOf(sp[j].charAt(0)).equals("#")) {
tag_name = sp[j];
String[] np = tag_name.split("#");
for (int k = 0; k<np.length; k++) {
if(np[k].length() >0 ) {
tag_name = np[k].replaceAll("\n", "");
System.out.println(""+ np[k]);
}
}
//System.out.println("" + tag_name);
}
}
Please suggest how can i do this using a more strong regex code.