I don't know how to find these words.. example I have this text...
The other day I went to the <location> and bought some <plural-noun> . Afterwards, I went to <location> , but it was very <adjective> so I left quickly and went to <location> .
I don't know what to search cause when I search <
and >
on google, it will be ignored. Need help how to get this string.
so I will get the <location>
, <plural-noun>
, <location>
, <adjective>
, <location>
I must use the charAt()
method. My attempt:
String string = this.fileName;
for(int i = 0; i < string.length(); i++)
if((string.charAt(i) == '<') && (string.charAt(i) == '>'))
System.println(""); //<-------- IM STUCK HERE
I don't know... almost two days no sleep.
My current but one last problem... How to remove <
and >
on each word on display?
String string = this.template;
Pattern pattern = Pattern.compile("<.*?>");
Matcher matcher = pattern.matcher(string);
List<String> listMatches = new ArrayList<String>();
while(matcher.find()) {
listMatches.add(matcher.group());
}
// System.out.println(listMatches.size());
int indexNumber = 1;
for(String s : listMatches) {
System.out.println(Integer.toString(indexNumber) + ". " + s);
indexNumber++;
}