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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T16:08:34+00:00 2026-05-23T16:08:34+00:00

We have a pair of strings for example such pair Accept-Language : RU ,

  • 0

We have a pair of strings for example such pair Accept-Language : RU , and we search thru map, for example of http request headers. All we ned to know if there is such pair in map or not – a bool value. How to do to a soft search meaning we do not need to find exact same pair but pair like Accept-Language : ru-RU,ru;q=0.8,en-US;q=0.6,en;q=0.4 is also a valid pair for us and if such exists we can think we have found that our map contains our pair. How to make a function for performing such search in C++?

  • 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-23T16:08:35+00:00Added an answer on May 23, 2026 at 4:08 pm

    First of all, if you are using a map, you cannot have multiple entries with the same key. E.g. you can’t have both Accept-Language : RU and Accept-Language : ru-RU,ru;q=0.8,en-US;q=0.6,en;q=0.4 because they have the same key `Accept-Language’. Perhaps in your case you should use a vector of pairs, or a multimap.

    Next, your question consists of 2 parts:

    1. How to check, whether some element (such as string or pair)
      matches a pattern.
    2. Assuming you have
      such a check, how to apply it to
      each element in a container.

    The solutions to each part:

    1. You can implement a function that takes a string, or a pair (depends on the type of container and stored element that you choose), and checks whether it matches your criteria. You can find the functions such as string::find_first_of to be useful for that matter. The regex libraries can be even more helpful, though they are not part of the STL.
    2. You can apply this function on every element of your container using find_if algorithm.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a situation where I want to map a pair of objects to
I have another one question about functions reference. For example, I have such definition:
I have a map container. I want to copy all its keys with user
I have strings that look like this example: AAABBBCDEEEEBBBAA Any character is possible in
I have an std::map and I want to search for a key using a
I have a pair of shell programs that talk over a named pipe. The
I have a pair of static fields with a complicated one-time initialization. I want
If I have a pair of dates, and I want to generate a list
I have a public/private key pair set up so I can ssh to a
If I have a vector of pairs: std::vector<std::pair<int, int> > vec; Is there and

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.