how can I remove, with NSRegularExpression, the entire head-tag in a HTML file. Can some one give me a regex?
Thanks in advance,
Ph99Ph
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
There is none! HTML is a type-2 language and thus not parsable with a regular expression (type-3).
See this wiki article in case of doubt.
Lots of people use regex for parsing/editing HTML. This works quite well in simple cases but is utterly error prone.
This being said: You should have fairly reliable results with this regex:
This requires “.” to also match line breaks. If it doesn’t, then use this:
Again: This is error prone, don’t do it.
What you should use is an XML parser such as
NSXMLParser.