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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T07:53:46+00:00 2026-06-04T07:53:46+00:00

$str1='<option value=AAA>AAA</option><option value=BBB>BBB</option><option value=CCC>CCC</option>’; $str2='<option value=CCC>CCC</option><option value=DDD>DDD</option>’; I would like the expected result as

  • 0
$str1='<option value="AAA">AAA</option><option value="BBB">BBB</option><option value="CCC">CCC</option>';

$str2='<option value="CCC">CCC</option><option value="DDD">DDD</option>';

I would like the expected result as following. If some part of $str2 which is duplicated with part of $str1, then removing the duplicated part of $str2.

Expected result:

$expectedStr = '<option value="DDD">DDD</option>';

Can anyone help me?

  • 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-04T07:53:47+00:00Added an answer on June 4, 2026 at 7:53 am
    var str1='<option value="AAA">AAA</option><option value="BBB">BBB</option><option value="CCC">CCC</option>',
        str2='<option value="CCC">CCC</option><option value="DDD">DDD</option>',
    
        result = str2.replace(/<option .+?<\/option>/g, function(m) {
            return (str1.indexOf(m) > -1)? "" : m;
        });
    
    console.log(result); //returns <option value="DDD">DDD</option>
    

    (here I’m supposing you want to check for “atomic” substring <option>...</option>)

    Example fiddle: http://jsfiddle.net/jAyAE/

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

Sidebar

Related Questions

Assuming I have the following strings: string str1 = Hello World!; string str2 =
I'd like to do something like this String.concat '\n' [str1; str2 ... strn] so
Right now I have the following code: String[] values = {str1, str2}; Utils.myMethod(values); I
we make the following String objects? String str1 = new String(ABC); String str2 =
i have a sample str1 14 girls str2 178 guys i tried the following
Consider the following piece of code: char* str1 = new char [30]; char* str2
I have a line bookval_int_curr = [str1 intValue] - [str2 intValue]; But for some
I have the following variables: string str1 = 1; string str2 = asd; string
I know you can concatenate a string like this in Javascript: str1 + str2;
string str1(someString); string str2 = string(str1);//how many copies are made here //copy2 = copy1?

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.