-1

Is there a way to loop through all backreferences in a regex replace scenario? To better understand what I am asking for:

Given you have the following text

Item 1, Item 2, Item 3

When you have a regex that matches an arbitrary number of items like

(([\w \d]+),?)*

Then you want the result to be something along the lines

<ul>
    <li>Item 1</li>
    <li>Item 2</li>
    <li>Item 3</li>
</ul>

Basically I'm searching for the right pattern in the Replace with field e.g. in notepad++ or whatever editor that supports extended regex stuff: enter image description here

Is that even possible?

baumgarb
  • 1,955
  • 3
  • 19
  • 30
  • 1
    Place the `
      ` manually, the rest is trivial. What you want here is the job of a templating engine. Regex is not complex enough to do this, I'm afraid (_and it's too complex already, as is_)
    – Sergio Tulentsev Mar 05 '18 at 12:10

1 Answers1

1

You can't do this in a single replacement, no. However, you could do it using multiple replacements.

If you search for the regex ([^,]+),? and replace with <li>\1</li> (or maybe <li>$1</li>. I'm not familiar with how N++'s regex engine works) it will replace each of your list items with an HTML list item.

All you need to do after that is put <ul> tags around the result.

squirl
  • 1,636
  • 1
  • 16
  • 30