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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T09:55:33+00:00 2026-06-09T09:55:33+00:00

regex pattern /}/ sometimes matches } and sometimes doesn’t. Is there any know bug

  • 0

regex pattern /}/ sometimes matches } and sometimes doesn’t.

Is there any know bug in PHP?
I am using PHP 5.40

I am assuming that } doesn’t need to be escaped for match.
Although /\}/ always matches } but this behavior seems to be wrong.

This link also says 11 metacharacters that need to be escaped only.

there are 11 characters with special meanings: the opening square bracket [, the backslash \, the caret ^, the dollar sign $, the period or dot ., the vertical bar or pipe symbol |, the question mark ?, the asterisk or star *, the plus sign +, the opening round bracket ( and the closing round bracket ). These special characters are often called “metacharacters”.

for an example - is a metacharacter as per PHP documentation but that doesn’t need to be escaped and /-/ works fine in PHP, why not }?

$subject = 'find me}';
$pattern = '/}/';
$isMatch = preg_match($pattern,$subject,$matches);

echo 'Match Found = ' . $isMatch . '<br />';
print_r($matches);

sometimes i get following

Match Found = 0
Array ( ) 

sometimes i get following

Match Found = 1
Array ( [0] => } ) 
  • 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-09T09:55:34+00:00Added an answer on June 9, 2026 at 9:55 am

    http://php.net/manual/en/function.preg-quote.php according to that { and } are regular expression characters

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

Sidebar

Related Questions

I am using the matches string builtin and need to run a regex pattern
I have a Regex pattern that matches data I need to parse exactly as
I currently have a regex pattern that matches a specific word, which includes arbitrary
I need a RegEx pattern which matches from where to the end of the
Is there a regex pattern that will match a string that contains repeated pattern,
What's a regex pattern (in PHP) that replaces img string with links, where tag
I need a regex pattern that validates a password format. The rules are: Minimum
I have got this regex pattern that works with my current apache log format:
I am using the XML regex pattern to match my proxy URL. eg: Proxy
could someone help me with the regex pattern that i could use to match

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.