Can someone please help me understand this bit of code with an example. I have been struggling just to get my head around this code.
URLResource file = new URLResource("http://www.dukelearntoprogram.com/course2/data/manylinks.html");
for (String item : file.words())
{ String itemLower = item.toLowerCase();
int pos = itemLower.indexOf("youtube.com");
if (pos != -1) {
int beg = item.lastIndexOf("\"",pos);
int end = item.indexOf("\"", pos+1);
System.out.println(item.substring(beg+1,end));
I am struggling with the lastIndexOf, IndexOf and the Substring bit.
Here is a sample YouTube URL:
youtube.com/channel/UCUZHFZ9jIKrLroW8LcyJEQQ