var s = "1. TLorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, \
2. quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse \
3. whatever..."
s.replace('/^\d\.\s+/gm','</li><li>')
I'm trying to convert a list structure copied from MS word to HTML list. I know ^
can match the 'start of string' anchor, he regex /^\d\.\s+/gm
will match every new line. But I need to distinguish the very first new line, which is the unique "start of whole string" anchor, a.k.a replace the first matching of /^\d\.\s+/
with <ol><li>
, is there any general way to do this?