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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T13:31:56+00:00 2026-06-11T13:31:56+00:00

I have preg_replace function that I’m calling and putting on multiple lines for readability

  • 0

I have preg_replace function that I’m calling and putting on multiple lines for readability but the */ characters in the regex mess up the comments. How can I comment out all these lines without moving them all onto one line?

return preg_replace('/.*/',
    'Lorem Ipsum' .
    'More Lorem Ipsum'
    ,
    $foo);
  • 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-11T13:31:57+00:00Added an answer on June 11, 2026 at 1:31 pm

    You could use a different regex pattern delimiter character:

    return preg_replace('#.*#',
        'Lorem Ipsum' .
        'More Lorem Ipsum'
        ,
        $foo);
    

    EDIT:
    The delimiter character is a feature of PCRE (Perl Compatible Regular Expresssion). No PHP configuration is needed to use a different delimiter.

    Regexp Quote-Like Operators

    …you can use any pair of non-alphanumeric, non-whitespace characters
    as delimiters. This is particularly useful for matching path names
    that contain “/”, to avoid LTS (leaning toothpick syndrome).

    Quote and Quote-like Operators

    Non-bracketing delimiters use the same character fore and aft, but the
    four sorts of ASCII brackets (round, angle, square, curly) all nest

    These are all valid:

    '/.*/'
    '#.*#'
    '{.*}' /* Note that '{.*{' would be incorrect. */
    

    Take a look at PHP’s documentation on PCRE Patterns to see a really good overview.

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

Sidebar

Related Questions

I have a basic regex function that converts the hastags into links but the
I'm using php's preg_replace function, and I have the following regex: (?:[^>(),]+) to match
I have a little problem with preg_replace . I need a function that removes
I have a function that creates an HTML form lines View by placing the
I have regex patterns in PHP $s = preg_replace(#\[URL\=(.*)\](.*)\[\/URL\]#Ui, <a href=\$1\ target=\_blank\>$2</a>, $s); $s
currently, this is the preg_replace string that I have. $mtg_post['post_content'] = preg_replace([^\\x20-\\x7e], ,$ability); This
I have a problem with the preg_replace function, I am trying to convert some
I have a problem with the preg_replace function. In my code i will use
I have a function that parses text form posts and if there's a link
This is the function I have that checks if the entered security question and/or

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.