SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Zealot sifuhall's Avatar
    Join Date
    Jun 2001
    Location
    out of the sidehatch
    Posts
    135
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    How to replace multiple line breaks

    I'm trying to replace multiple line breaks in a field with a double line break, but only when there are 3 or more in a row.

    So for example I would want to replace \n\n\n with \n\n
    and \n\n\n\n with \n\n etc.

    I'm trying this but it doesn't seem to work
    Code:
    UPDATE xf_post SET message = REPLACE(message, '\n\n\n', '\n\n')

  2. #2
    SitePoint Evangelist
    Join Date
    Jun 2007
    Location
    North Yorkshire, UK
    Posts
    483
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Are you sure you just have \n as a new line not \r\n?


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •