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

  • Home
  • SEARCH
  • 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 7579835
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T17:46:09+00:00 2026-05-30T17:46:09+00:00

If there are two separate strings, we need to retrieve all words that are

  • 0

If there are two separate strings, we need to retrieve all words that are matching (in those strings), in an array. also this matching should be case insensitive. What will be the most efficient way to achieve this.

For Example:

NSString *s1 = @"Hello there, I want to match similar words.";  
NSString *s2 = @"Do you really want to match word, hello?";  

The resulting array should contain, "hello", "want", "to", "match".

I went through many questions and, responses over the net like Regular expression to match a line that doesn't contain a word?, but didn’t, find solution needed.

  • 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-05-30T17:46:10+00:00Added an answer on May 30, 2026 at 5:46 pm

    You can use NSMutableSet for this..

        NSString *s1 = @"Hello there, I want to match similar words.";  
        NSString *s2 = @"Do you really want to match word, hello?"; 
    
        NSArray *components = [s1 componentsSeparatedByString:@" "];
        NSArray *components1 = [s2 componentsSeparatedByString:@" "];
        NSLog(@"%@",components);
        NSLog(@"%@",components1);
    
        NSMutableSet *resultSet = [NSMutableSet setWithArray:components1];
        NSSet *setA = [NSSet setWithArray:components];
        [resultSet intersectSet:setA];
        NSArray *result = [resultSet allObjects];
        NSLog(@"%@",result);
    

    This Solution will work for you, If you don’t have any punctuations in the sentences.. If you want sentences with punctuations to work just remove all the punctuations in your sentences.

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

Sidebar

Related Questions

There are two scenarios I need to clarify: An executable compiled with .NET 3.5
I have a string say 123dance456 which I need to split into two strings
I have two strings: $first = '/this/is/a/string'; $second = '/this/:param1/a/:param2'; And I'm trying to
Really got stuck on this simple regex. Need it to validate a string, that
I need to capture such string as a TWO separate matches: MLB m L
The following snippet does work for what I need. I believe though that there
I need to mash a list of strings together using one or two properties
We have two separate web-apps, say 'retailUI' and 'bulkUI'. These two are basically two
Why did MS originally make the decision to maintain these two separate core libs?
There are two weird operators in C#: the true operator the false operator If

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.