premmac
premmac

Reputation: 83

IOS NSString replace text in between a range

Update: I forgot to mention that i have a big string of html and this src="" is a part of it. So, my question is how to find this particular "file:///.../" and remove it ?

How can I replace a NSString value

src="file:///var/mobile/Applications/92AE599A-1231223151B-4B3A-8C9B-950225AF5971/something.app/smiley-1.png"

to

src="smiley-1.png"

Upvotes: 2

Views: 237

Answers (2)

deleted_user
deleted_user

Reputation: 3805

src = [src lastPathComponent];

Upvotes: 3

Krishnabhadra
Krishnabhadra

Reputation: 34265

you can use componentsSeparatedByString function of NSString

NSArray *array  =  [src componentsSeparatedByString:@"/"];
src             =  [array lastObject];

Upvotes: 0

Related Questions