Q:

how to replace part of a string in string?

i want to replace a string in a string. let me explain you what my exacvt aim is.  
This ist my String  
<p>Hello Webseite i want to replace<p>thisPTag</p>which is in the middle 
of the word or in the end of the sentence</p>.  

If i use  
[string stringByReplacingOccurrencesOfString:@"<p>" withString:@"|break|"]; 

it replaces only the first . But i want to replace ALL p tags, doesnt matter if in the sentence or not, white space before or after that also doesnt matter.
So how can i do that? 
Not really important but good to know:
please keep in mind that i dont want to strip html, i just want to replace the p-tag to set breaks there for correct SSML and TTS(textto speech)

A:

It works (all <p> are replaced). You probably just confusing <p> and </p>. These are different literals, so they would have to be replaced separately:
NSString * a = @"<p>Hello Webseite i want to replace<p>thisPTag</p>which is in the middle of the word or in the end of the sentence</p>. ";

NSString * b = [a stringByReplacingOccurrencesOfString:@"<p>" withString:@"|break|"];
b =  [b stringByReplacingOccurrencesOfString:@"</p>" withString:@"|break|"];

NSLog(@"%@",b);

This prints:

|break|Hello Webseite i want to replace|break|thisPTag|break|which is in the middle of the word or in the end of the sentence|break|. 

