Free Support Forum - aspose.com

I want use replace to add space in paragraph-but Not successful

I have code (Paragraph Content is:
1test2;
1.1test2
1.1.1test3,
I want my purpose is:
1-test2
1.1- test2(between 1.1 test2 is -)
1.1.1- test3
paragraph.Range.Replace(new Regex(@"(?<=^\d+\.\d+)\s*(?=\w)"), "-");//

Hi,


Thanks for your inquiry. In your case, I suggest you please use ListLevel.NumberFormat and ListLevel.NumberStyle properties for your requirement. Please read following documentation link for your kind reference.

http://www.aspose.com/docs/display/wordsnet/ListLevel+Members

Please check the following code snippet to work with List. If you are not using numeric lists in your document, please share your document for investigation purposes.

<span lang=“EN-GB” style=“font-family:“Courier New”;color:#2B91AF;mso-no-proof:yes”>Document<span lang=“EN-GB” style=“font-family:“Courier New”;mso-no-proof:yes”> doc = new Document();<o:p></o:p>

DocumentBuilder builder = new DocumentBuilder(doc);

Aspose.Words.Lists.List list = doc.Lists.Add(ListTemplate.NumberDefault);

list.ListLevels[0].NumberFormat = "1-";

list.ListLevels[0].NumberStyle = NumberStyle.Number;

list.ListLevels[1].NumberFormat = "1.1-";

list.ListLevels[1].NumberStyle = NumberStyle.Number;

list.ListLevels[2].NumberFormat = "1.1.1-";

list.ListLevels[2].NumberStyle = NumberStyle.Number;

// Apply list formatting to the current paragraph.

builder.ListFormat.List = list;

// Exercise the 3 levels we created two times.

for (int n = 0; n < 2; n++)

{

for (int i = 0; i < 3; i++)

{

builder.ListFormat.ListLevelNumber = i;

builder.Writeln("Level " + i);

}

}

builder.ListFormat.RemoveNumbers();

builder.Document.Save(MyDir + "AsposeOut.doc");