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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T14:32:58+00:00 2026-05-23T14:32:58+00:00

I am trying to use preg_replace to convert <br> or <br /> to a

  • 0

I am trying to use preg_replace to convert <br> or <br /> to a carriage return (&#13;). My problem seems to be that it either doesn’t find the <br>‘s or doesn’t recognize the hex code I’m trying to pass in. Here is my relevant PHP:

preg_replace('`<br(?: /)?>(\x{13}/u)`', '$1', $content);

Other Information: The strings I am passing in have &quot; but I don’t think that will interfere with preg_replace().

Here are a couple links that have helped me get this far:
http://www.webmasterworld.com/forum21/10973.htm (use carriage return instead of \n in tooltips)
https://www.php.net/manual/en/reference.pcre.pattern.modifiers.php#58409 (use \x{13} instead of &#13)

  • 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-23T14:32:59+00:00Added an answer on May 23, 2026 at 2:32 pm

    Hmmm, You seem to have preg_replace formatted a little strange. Not sure why your doing it with the backreferences like that? For something simple like this, the First variable should be the regex. 2nd should be replacement, and third should be subject:

    preg_replace('%<br.*?>%', '&#13;', $content);
    

    I think that will work, but I am not great at regexes. .*? should match any characters up to the next >

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

Sidebar

Related Questions

I'm trying to use preg_replace to replace &lt;a href=&quot;WWW.ANYURL.COM&quot;&gt;DISPLAY_TEXT&lt;/a&gt; with <a href=WWW.ANYURL.COM>DISPLAY_TEXT</a> here is
I'm trying to figure out an preg_replace() (php) style function that I can use
I'm having trouble with preg_replace and I'm not sure that I use correct function.
Am trying to use something like: $newdata = preg_replace($pattern, $replacement, $data); Now my replacement
I'm trying to use preg_replace to remove all characters from a string except for
I've been trying to use preg_replace to replace period within my string to comma
I'm trying to convert the following ereg() call to use preg_match() instead: if (ereg('(.*/)(.*)$',$fileref,$reg)
I was trying to use preg_replace on a string but I obtain a wrong
I'm trying to use preg_match to extract info from href=domain.com/subdir/?key=value The info I want
I'm trying to use PHP's split() (preg_split() is also an option if your answer

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.