I have a really long string, I just want to extract some certain string inside that string. How can I do that?
for example I have:
this is the image <img src="http://vnexpress.net/Files/Subject/3b/bd/67/6f/chungkhoan-xanhdiem2.jpg"> and it is very beautiful.
and yes now i want to get substring this long string and get only http://vnexpress.net/Files/Subject/3b/bd/67/6f/chungkhoan-xanhdiem2.jpg
Please show me how I can do this.
You can use regular expressions for this:
This regular expression is the heart of the solution:
It matches the content of the
srcattribute, and captures the content between the quotes (note a pair of parentheses). This caption is then retrieved in[r rangeAtIndex:1], and used to extract the part of the string that you are looking for.