Wrap many lines of text in list item tags using RegEx


So I have an email with a huge list of names. They are displayed one per line. I want to wrap them in list item tags so I can stick them in an unordered list. Here is how to do it fast and painlessly…

First, here is what I start with (just imagine 1000 names, rather than 3):

Bob Smith, Acme Corp, CEO
Janet Johnson, Barton Inc, VP for Development and Shoe Sizes
Cat Sims, Transmo Inc, VP of Conference Room Chair Height Adjustments

Here is the regex I will find and replace with:
Find:

(.*)\r

Replace (pretend that last “\r” is right next to the list item closing tag:

  • \1
  • \r

    The find code looks for anything with a carriage return at the end and then grabs the bit in the parenthesis.
    The replace code wraps that bit in the parenthesis (signified by the \1), wraps it in list item tags and sticks a carriage return on the end.

    Now my list looks like:

  • Bob Smith, Acme Corp, CEO
  • Janet Johnson, Barton Inc, VP for Development and Shoe Sizes
  • Cat Sims, Transmo Inc, VP of Conference Room Chair Height Adjustments
  •      
    1. No comments yet.
    (will not be published)