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 8901047
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T01:15:09+00:00 2026-06-15T01:15:09+00:00

I have to match 2 strings where at least one word is same, I

  • 0

I have to match 2 strings where at least one word is same, I need to give a success msg.

var str1 = "Hello World";
var str2 = "world is beautiful";

I need to match/compare these 2 strings, in both strings world is matching, So i need to print a success message. How do I go about it.

  • 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-15T01:15:10+00:00Added an answer on June 15, 2026 at 1:15 am

    The following code will output all the matching words in the both strings:

    var words1 = str1.split(/\s+/g),
        words2 = str2.split(/\s+/g),
        i,
        j;
    
    for (i = 0; i < words1.length; i++) {
        for (j = 0; j < words2.length; j++) {
            if (words1[i].toLowerCase() == words2[j].toLowerCase()) {
               console.log('word '+words1[i]+' was found in both strings');
            }
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

string = 'Hello _1234_ world _4567_'; string.match(/(\d*)/gi); //,,,,,,,1234,,,,,,,,,,4567,, If I change regext to have
I have read that to match a word inside of a string using Regular
I need to be able to match strings like: GQG6VJ6K , TYTU-TIDM-56 , 4-5-P-Z
Given 2 strings, I want to find the first match of at least four
I have a function that returns True if a string matches at least one
i need to test if any of the strings 'hello', 'i am', 'dumb' exist
I have Django model and in one of the fields I need to store
Is this Regex correct if I have to match a string which is atleast
I have a Perl script, that's supposed to match this string: Sometimes, he says
I am trying to match on a string that begins with ./media I have

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.