Why is this code only spitting out the entire regex match instead of the capture group?
Input
@\"A long string containing Name:>
Don't parse HTML with regular expressions or NSScanner. Down that path lies madness.
This has been asked many times on SO.
parsing HTML on the iPhone
The data i am picking out is as simple as
and i think its simple enough to just use regular expressions instead of including a full blown HTML parser in the project.Name: A name
Up to you and I'm a strong advocate for "first to market has huge advantage".
The difference being that with a proper HTML parser, you are considering the structure of the document. Using regular expressions, you are relying on the document never changing format in ways that are syntactically otherwise perfectly valid.
I.e. what if the input were ? Your regex parser just broke on input that is both valid HTML and, from a tag contents perspective, identical to the original input.Name: A name