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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T04:03:04+00:00 2026-06-05T04:03:04+00:00

im making a simple word game with php and regex, how can we search

  • 0

im making a simple word game with php and regex, how can we search that if a string have to require two or more words?

lets say

"cat"
"dog"
"play" x 2

if

“cat dog play play” pass

“hello a cat dog playing a play” not pass, only 1 “play”

“cat” not pass, no dog and 2x play

“i want a cat and a dog play with me and play with grandfather” pass

how can we match it with regex?

  • 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-05T04:03:06+00:00Added an answer on June 5, 2026 at 4:03 am

    The regex you’re looking for is:

    /(?=.*?\bcat\b)(?=.*?\bdog\b)(?=(.*?\bplay\b){2})^.*$/
    

    Explanation: I believe words cat, dog and play (twice) can appear in the text in any order but they must all be present in the sentence to qualify. Above regex is using positive lookahead to make sure the presence of above conditions.

    Here is the online working demo of above RegEx

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

Sidebar

Related Questions

I am making simple connection between two table - first one called users has
in making a simple cgi server for a course. To do that in some
I'm making a simple MP3Player in Java. I have managed to play a .mp3
I am making a simple Java Swing GUI chessboard where the player can drag
I am making simple graphical game in WinForms and currently I would like to
I'm making simple game with very simple thread (1 sec delay) got problem with
i am making simple autosuggestion (autocompleter) plugin with jQuery. Unfortunately i have to use
I'm making simple http post request using libcurl to index.php file on my web
I am making simple ANSI C program, that simulates Unix shell. So I am
I'm making simple php chat, and i need to refresh messages in one div.I

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.