1

I'm breaking my head to come up with a replace regex pattern to convert

* foo
***** bar
*** foobar

to:

1 foo
5 bar
3 foobar

That is, replacing the number of appearances of the star at the beginning of each line.

So far I tried:

bulletpoints=/^( )*(\*)*( )+/gm
x.replace(bulletpoints, `${$2.length}`);

But to no avail...

Can I get some assistance?

Thank you!

ggonmar
  • 760
  • 1
  • 7
  • 28

0 Answers0