I am developing an app based on the programming joke blog I have created.
In each post there is an html body that includes the image and a NSString in the following format:
/* by AUTHOR (SOMETIMES WITH SPACES etc) */
I would like to use regex to extract this author name, minus the other text. Can anyone give an example of how to do this?
EDIT:
I need the ???? line:
NSString *result = [htmlString stringByReplacingOccurrencesOfString: ????
withString:@"$1, "
options:NSRegularExpressionSearch
range:NSMakeRange(0, [htmlString length])];
If your text is always in the same format, i.e. /* TEXT */ you don’t need an regex, but you could do this with a substring with range. Else if you want a regex, here is a link to the solution
You could also see this page