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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T15:27:36+00:00 2026-06-18T15:27:36+00:00

Using php, what is the regex to match an exact string. Say we have

  • 0

Using php, what is the regex to match an exact string.

Say we have the text:

Hello, world. 

How are you today?

Today is sunshine and snow wouldn't you know.

How would I use regex to match the string?:

sunshine and snow
  • 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-18T15:27:38+00:00Added an answer on June 18, 2026 at 3:27 pm

    Using preg_match:

    <?php
    // The "i" after the pattern delimiter indicates a case-insensitive search
    if (preg_match("/php/i", "PHP is the web scripting language of choice.")) {
        echo "A match was found.";
    } else {
        echo "A match was not found.";
    }
    ?>
    

    Using strpos:

    <?php
    $mystring = 'abc';
    $findme   = 'a';
    $pos = strpos($mystring, $findme);
    
    // Note our use of ===.  Simply == would not work as expected
    // because the position of 'a' was the 0th (first) character.
    if ($pos === false) {
        echo "The string '$findme' was not found in the string '$mystring'";
    } else {
        echo "The string '$findme' was found in the string '$mystring'";
        echo " and exists at position $pos";
    }
    ?>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using php's preg_replace function, and I have the following regex: (?:[^>(),]+) to match
Im parsing the source of a website and Im using this regex: /page\.php\?id\=([0-9]*)\\>(.*)\<\/a\>\<\/span\>/.match(self.agent.page.content) self.agent.page.content
Assuming the input string +123-321+123 345 , using PHP's regex functions I would like
I want to copy a substring of a string using PHP. The regex for
Possible Duplicates: How do I extract HTML content using Regex in PHP RegEx match
Possible Duplicate: php regex , extract phone number from text/html I have following requirement.
I'm using PHP. I'm trying to get a Regex pattern to match everything between
I'm using PHP's preg_match_all() to search a string imported using file_get_contents(). The regex returns
I'm using PHP preg_replace with the following regex: /(?<=#EXTINF:([0-9])+,).+?(?=#EXT)/gsm operating on the following string:
I am trying to parse text for email id's using php / regex. Are

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.