I have text with this structure:
1. Text1 2. Text 2. It has a number with a dot. 3. 1. Text31
I want to get this text:
# Text1
I tried to do the following but not working
var pattern = @"^(\s*\d+\.\s*)+"; var replaced = Regex.Replace(str, pattern, "#", RegexOptions.Multiline);
Basically, it should start matching at the beginning of each line and replace each matching group with the # character. Currently, if more than one group is matched, everything is replaced with a single # character. I am using the template, probably the wrong one, can anyone come up with a solution?
source share