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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T21:16:26+00:00 2026-06-11T21:16:26+00:00

I went through a few basics on preg match but its quite difficult when

  • 0

I went through a few basics on preg match but its quite difficult when your new to it.

What im trying to do is search for this instance in a string

bug1234

it shouldnt be case sensitive so bug1234 or BuG1234 should work
it must be the word bug followed by any 4 numbers
there should be no spaces or anything in between bug1234 so bug-1234 should not be a match
it should ignore things like bug1234z and abug1234 so it must be bug1234 with nothing prefixing it or coming directly after it unless there is a space between then so “there is a problem with bug1234 that i cant solve” would be a match.

Just to clarify it can be any number not 1234 specifically but they must be 4 digits

Heres my lame attempt:

$file_string = $workdetails->text;
$file_string = strtolower($file_string);
$bugkey = "/bug[0-9]{4}/";
$nosey = preg_match($bugkey, $file_string);
if($nosey !== false) 
{
echo "We have a match baby!!"
}

That just seemed to return all sorts, empty string,s string with no mention of the word bug

  • 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-11T21:16:27+00:00Added an answer on June 11, 2026 at 9:16 pm

    Try changing the regex to:

    /\bbug[0-9]{4}\b/i
    

    The \b modifier will only match on a word boundary so that makes sure it doesn’t match things like abug1234, bug12345 or bug1234was bad. I also added the i modifier so it is case insensitive. You no longer need to use strtolower.

    Also, preg_match typically returns an integer, and returns (int)0 if there is no match. It only returns FALSE on failure. Therefore you should change the match check to be:

    if ($nosey > 0) {
    // or just
    if ($nosey) {
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Yes, I've read the developer documentation and even went through a few tutorials... but
Ok, this is really really easy, but even though I went through 100s of
I went through few post but didn't find an answer to probably one of
i think this question was asked few times, which I have went through and
I went through this whole procedure http://www.hanselman.com/blog/WorkingWithSSLAtDevelopmentTimeIsEasierWithIISExpress.aspx a couple weeks ago and got https
I went through the example from apple MoviePlayer on iPhone Im trying to overlay
I went through the dev portal provisioning process twice now trying to get it
As I went through this wonderful blog by Mike McCandless explaining the power of
I have went through a few links here, not all of them, regarding MKPinAnnotationView
I went through few blogs and sites which gave me some information about how

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.