0

I have a string:

<img src="https://google.com">

I would like to extract https://google.com from this this, ie, the substring after the last " or first " from right.

Could someone please provide some help?

I could not input " " " into the line below,it keep give me error.

line.lastIndexOf(""")
newbieprogrammer
  • 848
  • 7
  • 23
  • 46

2 Answers2

0

line.lastIndexOf(""") gives an error because the compiler cannot differentiate between the 3 " and when matches 2 of them to form a pair, the 3rd one remains unmatched.

Use an escape character \. So line.lastIndexOf("\""); will do what you intend to do, get the index of the last occurence of ".

Sinstein
  • 887
  • 11
  • 42
0

you have to escape it (the double quote) with backslash.

line.lastIndexOf("\"");