在objective c中从HTML解析电子邮件地址

在objective c中从HTML解析电子邮件地址,html,objective-c,parsing,Html,Objective C,Parsing,这是HTML,我只需要从中获取“user@website.com". 我正在使用的HTML解析器您可以在这里找到: 我通过使用第一个孩子、下一个兄弟姐妹等等修改了我的代码一百万次,但什么都没有 谢谢你的帮助 您可以使用正则表达式提取exp的电子邮件: NSString *regex = @"[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,4})"; for (NSString *match in [htm

这是HTML,我只需要从中获取“user@website.com".

我正在使用的HTML解析器您可以在这里找到:

我通过使用第一个孩子、下一个兄弟姐妹等等修改了我的代码一百万次,但什么都没有


谢谢你的帮助

您可以使用正则表达式提取exp的电子邮件:

NSString *regex = @"[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,4})";
for (NSString *match in [html componentsSeperatedByRegex: regex]{
    NSLog (@"%@", match); 
}
NSArray *emailNodes = [bodyNode findChildTags:@"td"];


    for (HTMLNode *inputNode in emailNodes) {
        if ([inputNode findChildrenWithAttribute:@"valign" matchingName:@"top" allowPartial:NO]) {

                NSLog(@"%@", [[inputNode getAttributeNamed:@"href"] stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]]);
NSString *regex = @"[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,4})";
for (NSString *match in [html componentsSeperatedByRegex: regex]{
    NSLog (@"%@", match); 
}