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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T23:02:55+00:00 2026-05-30T23:02:55+00:00

The pattern below seems to work in regex editors, but it doesn’t work in

  • 0

The pattern below seems to work in regex editors, but it doesn’t work in PHP (no error).
I thought by adding delimiters and running the pattern through preg_quote would address this.
Would appreciate any help on what step I’m missing here.

Code sample:

$pattern = '%(?<=@address|.)singleline(?=[^\]\[]*\])%';  
$pattern = preg_quote($pattern);
$output  = preg_replace($pattern, "", $output);

HTML Sample:

  <p>[@address|singleline]</p>
  • 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-30T23:02:57+00:00Added an answer on May 30, 2026 at 11:02 pm

    preg_quote escapes characters that are regular expression syntax characters. These include . \ + * ? [ ^ ] $ ( ) { } = ! < > | : -. Try not using preg_quote.

    $pattern = '%(?<=@address|.)singleline(?=[^\]\[]*\])%';  
    $output  = preg_replace($pattern, "", $output);
    

    EDIT:
    You might want to use preg_quote if you had content you wanted to include in your regex pattern which contained characters used in regex syntax. For example:

    $input = "item 1 -- total cost: $5.00";
    $pattern = "/total cost: " . preg_quote("$5.00") . "/";
    // $pattern should now be "/total cost: \$5.00/"
    $output = preg_replace($pattern, 'five dollars', $input);
    

    In this case, you need to escape the $ because it is used in the regex syntax. To search for it, your regex should use \$ instead of $. Using preg_quote performs this alteration for you.

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

Sidebar

Related Questions

I have a powershell script (below) which seems to work but prints an error
It seems to me the snippet below should work, but mp.getBodyPart(1).getContent().toString() returns com.sun.mail.util.BASE64DecoderStream@44b07df8 instead
I get the error below on several views. Which seems identical to what is
I have pattern like below hi hello hallo greetings salutations no more hello for
I'm maintaining a web application that utilizes the provider pattern as described below, for
What is the RegEx pattern for DateTime (2008-09-01 12:35:45 ) ? I get this
I implemented a plugable framework like below. It works but I'm confused about the
In an application I work on, any business logic error causes an exception to
I have seen someone write below kind of Func<> pattern. And I am trying
I have a class that implements singleton pattern as you can see below: public

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.