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

  • Home
  • SEARCH
  • 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 3484650
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T10:48:45+00:00 2026-05-18T10:48:45+00:00

Parsing an array of string commands, I need to know if a string contains

  • 0

Parsing an array of string commands, I need to know if a string contains a specific keyword.

Sounds simple I know, but the problem comes when the command keyword may also be part of another word.

Ex:

CHECKSOUND
SOUND
CHECK

So I need to check if the current line has the CHECKSOUND, SOUND, or CHECK command.

If I use something like:

if(stristr($line,'SOUND') == true)

Then it may find CHECKSOUND before SOUND and thus not parse correctly.

Question:

Is there a way to find only an occurrence of a whole word like SOUND and ignore the occurrence SOUND if found as part of another word like CHECKSOUND?

I am sure I am missing something simple here.

  • 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-18T10:48:46+00:00Added an answer on May 18, 2026 at 10:48 am

    You can use a regular expression to easily achive the goal.

    Example #2 from the documentation of preg_match:

    /* The \b in the pattern indicates a word boundary, so only the distinct
     * word "web" is matched, and not a word partial like "webbing" or "cobweb" */
     if (preg_match("/\bweb\b/i", "PHP is the web scripting language of choice.")) {
         echo "A match was found.";
     } else {
         echo "A match was not found.";
     }
    

    Note that the above example uses the i modifier, which makes the search for “web” case insensitive.

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

Sidebar

Related Questions

I write a number of simple scala scripts that end up starting with a
Following the Android sample for populating a ListView , I query an array from
I am reading some lines from a file in the following format: Identifier String
I would like to read a (fairly big) log file into a MATLAB string
I have a little script that replace some text, that come from a xml
I'm trying to keep the values of checkboxes in a form with the same
Here is my code for the function function multiple_delete($checkbox, $table = 0, $url =
I'm building a CLI survey app in Java that lets users answer multiple-choice questions.
I am having trouble passing data from one activity to another. I can easily
Language = C#.NET Anything that is between [STX] and [ETX] must be accepted rest

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.