Replace "<br />" with newline?

6 months ago | thingles (Member) | |

Search Regex is awesome and has saved me a ton of time. I've been able to clean up hundreds of old blog posts.

I have one situation that I can't seem to figure out the right fix for. I have a couple hundred posts that were imported from another blog. That blog inserted "
" with every newline. I'd like to purge the "
" out and replace with a newline character.

I can't seem to get a newline character in though. I tried "\n" and "\\n" on the replace string but both cases just put a "\n" in the text.

Any ideas on how to get a newline in?

Read responses...

Responses

  1. thingles:

    Posted 6 months ago by Member

    Okay, seems that post got confused on the breaks. Both of those should be "
    ".

  2. thingles:

    Posted 6 months ago by Member

    Ugh -- seems that even HTML entity tags get converted... [less than]br /[greater than]

  3. John:

    Posted 6 months ago by Key Master

    An interesting problem! I've added this to the feature request list as it's probably something that cannot be done as the plugin stands.

  4. thingles:

    Posted 6 months ago by Member

    I sort of figured out how to do this. What I did was do the search with a regex that captured the newline (\n) and then used the $x to put that into the replacement. Worked fine, but had to be applied over and over since multiple instances wouldn't match in the same regex.

    I think it was something like.

    /(.*)<br \/>(.*)(\n)/

    with

    $1$3$2

Reply

You must log in to post.

Home | Software | Terms & Conditions | Sitemap | John Godley © 2008