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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T23:59:52+00:00 2026-05-23T23:59:52+00:00

I give an example to easily describe the problem. Input text: Wayne Rooney is

  • 0

I give an example to easily describe the problem.

Input text:
Wayne Rooney is an English footballer who plays as a striker for Manchester United. Rooney became the youngest player to play for England when he earned his first cap in a friendly against Australia. Theo Walcott broke Rooney’s appearance record by 36 days in May 2006.

Input keyword: wayne rooney

Expected output (keyword count): 3 (wayne rooney, rooney, rooney’s)

So, it doesn’t only count “wayne rooney”, but also other similar words.

I have searching over SO, I got this regex:

$keyword_count = preg_match_all("/(\w*(?:wayne|rooney)\w*)/i", $source, $res);

But it gives me 4 as the output. It counts “wayne rooney” as two different keywords.

Could anyone help me to construct the correct formula?
Is Regex really the most efficient solution for this? I have a high volume of text to search. Any other solution, for example Text Mining library for PHP?

Thanks a lot.

  • 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-23T23:59:52+00:00Added an answer on May 23, 2026 at 11:59 pm

    Try this regex:

    (?i)(\b(?:wayne(?:'s)?\s*)?rooney(?:'s)?\b)
    

    If you have limited count of regular rules to parse string, regex is appropriate to solve your problem. In general case you should use other methods (may be several regex).

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

Sidebar

Related Questions

Can anybody give an example of c++ code that can easily convert a decimal
Could you give an example where static_assert(...) ('C++11') would solve the problem in hand
I know how to do this... I'll give example code below. But I can't
To give an example of the kind of request that I can't figure out
Can someone give an example of a good time to actually use unsafe and
Can you give an example where the Queue data structure can be specially helpful
Can someone give an example for finding greatest common divisor algorithm for more than
Can you give an example of stack overflow in C++?
Could anybody give an example to demonstrate the usage of the Invariant Culture ?
Can someone give an example of how thread deadlock can be caused in the

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.