swift - Iterate through string characters to remove blockquotes -


i have string url , want remove blockquotes , characters after string.

string looks http://pics.v6.top.rbk.ru/v6_top_pics/resized/250xh/media/img/7/92/754435534528927.jpg\"><div>Какой-то div</div>

so try make for-loop iterates through every character appending new string , stops when finds blockquotes

i try following code

var value = "http://pics.v6.top.rbk.ru/v6_top_pics/resized/250xh/media/img/7/92/754435534528927.jpg\"><div>Какой-то div</div>" var result = string() char in value.characters { var = false if char == "\"" {     let temp: character = "\""     result.append(temp)     = true } else if != true {     result.append(char) } } print(result) 

but not work

also try while, causes infinite loop

for char in value.characters { while char != "\"" {     print("hello") } } 

how correctly ?

thanks in advance!

upd - dont need remove quotes. need remove them , after them

if want remove characters double quote until end of string, easier index of substring rangeofstring()

let value = "http://pics.v6.top.rbk.ru/v6_top_pics/resized/250xh/media/img/7/92/754435534528927.jpg\"><div>Какой-то div</div>" if let offsetoffirstdoublequote = value.rangeofstring("\"") {   let result = value.substringtoindex(offsetoffirstdoublequote.startindex)   print(result) } 

or, more specific, if separator ">

if let offsetofdoublequotegreaterthan = value.rangeofstring("\">") {   let result = value.substringtoindex(offsetofdoublequotegreaterthan.startindex)   print(result) } 

Comments

Popular posts from this blog

html - Outlook 2010 Anchor (url/address/link) -

javascript - Why does running this loop 9 times take 100x longer than running it 8 times? -

Getting gateway time-out Rails app with Nginx + Puma running on Digital Ocean -