Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

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.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8987101
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T21:42:33+00:00 2026-06-15T21:42:33+00:00

I am making an iphone application. I have a scenario where i have a

  • 0

I am making an iphone application. I have a scenario where i have a huge string, which has lot of data, and i would like to extract only email addresses from the string.

For example if the string is like

asdjasjkdh asdhajksdh jkashd sample@email.com asdha jksdh asjdhjak sdkajs test@gmail.com

i should extract “sample@email.com” and “test@gmail.com”

and i also want to extract only date, from the string

For example if the string is like

asdjasjkdh 01/01/2012 asdhajksdh jkas 12/11/2012 hd sample@email.com asdha jksdh asjdhjak sdkajs test@gmail.com

i should extract “01/01/2012” and “12/11/2012”

A small code snipet, will be very helpful.

Thanks in advance

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T21:42:34+00:00Added an answer on June 15, 2026 at 9:42 pm

    This will do what you want:

    // regex string for emails (feel free to use a different one if you prefer)
    NSString *regexString = @"([A-Za-z0-9_\\-\\.\\+])+\\@([A-Za-z0-9_\\-\\.])+\\.([A-Za-z]+)";
    
    // experimental search string containing emails
    NSString *searchString = @"asdjasjkdh 01/01/2012 asdhajksdh jkas 12/11/2012 hd sample@email.com asdha jksdh asjdhjak sdkajs test@gmail.com";
    
    // track regex error
    NSError *error = NULL;
    
    // create regular expression
    NSRegularExpression *regex = [NSRegularExpression regularExpressionWithPattern:regexString options:0 error:&error];
    
    // make sure there is no error
    if (!error) {
    
        // get all matches for regex
        NSArray *matches = [regex matchesInString:searchString options:0 range:NSMakeRange(0, searchString.length)];
    
        // loop through regex matches
        for (NSTextCheckingResult *match in matches) {
    
            // get the current text
            NSString *matchText = [searchString substringWithRange:match.range];
    
            NSLog(@"Extracted: %@", matchText);
    
        }
    
    }
    

    Using your sample string above:

    asdjasjkdh 01/01/2012 asdhajksdh jkas 12/11/2012 hd sample@email.com asdha jksdh asjdhjak sdkajs test@gmail.com

    The output is:

    Extracted: sample@email.com
    Extracted: test@gmail.com
    

    To use the code, just set searchString to the string you want to search. Instead of the NSLog() methods, you’ll probably want to do something with the extracted strings matchText. Feel free to use a different regex string to extract emails, just replace the value of regexString in the code.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am making an iphone application which has a zip code field. When the
I am Making an Iphone application which is web-service enabled. Also I have skeleton
I have an iPhone application using UINavigationController and would like to customize the elements
I am making a small iPhone application in which I have implemented the database
I am making an application (iPhone app) which gets information (jokes) from an RSS
I have a simple iPhone application I am making that will upload pictures to
I have started learning titanium framework.I was making application into iphone.I have made application
I am making a simple iphone application where I have certain textfields one below
I have an RMI application that has service implementation and it has a lot
I'm making an iphone only app, so far I have been able to share

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.