using System;
using System.Text.RegularExpressions;
public class Example
{
public static void Main()
{
string pattern = @"^\d+.";
string substitution = @"";
string input = @"1. // #include <conio.h>
2. // #include <stdio.h>
3. #include <iostream>
4. // #include <ctype.h>
5. #include <cstring>
6. using namespace std;
7. class CON_VAT
8. {
9. protected:
10. char *ten;
11. public:
12. CON_VAT()
13. {ten = NULL;
14. }
15. CON_VAT(char *ten1)
16. {
17. strcpy(ten,ten1);
18. }
19. virtual void xung_ten()
20. { }
21. } ;
22. class CON_MEO:public CON_VAT
23. {
24. public:
25. CON_MEO() : CON_VAT()
26. { }
27. CON_MEO(char *ten1) : CON_VAT(ten1)
28. { }
29. virtual void xung_ten()
30. {
31. cout << ""\nToi la chu meo: "" << ten ;
32. }
33. };
34. class CON_CHO:public CON_VAT
35. {
36. public:
37. CON_CHO() : CON_VAT()
38. { }
39. CON_CHO(char *ten1) : CON_VAT(ten1)
40. { }
41. virtual void xung_ten()
42. {
43. cout << ""\nToi la chu cho: "" << ten ;
44. }
45. };
46. class DS_CON_VAT // Danh sach con vat
47. {
48. private:
49. int max_so_con_vat;
50. int so_con_vat;
51. CON_VAT **h ;
52. public:
53. DS_CON_VAT(int max);
54. ~DS_CON_VAT();
55. int nhap(CON_VAT *c);
56. CON_VAT* xuat(int n);
57. void thong_ke();
58. } ;
59. DS_CON_VAT::DS_CON_VAT(int max)
60. {
61. max_so_con_vat = max;
62. so_con_vat = 0;
63. h = new CON_VAT*[max];
64. for (int i=0; i<max; ++i)
65. h[i] = NULL;
66. }
67. DS_CON_VAT::~DS_CON_VAT()
68. {
69. max_so_con_vat = 0;
70. so_con_vat = 0;
71. delete h;
72. }
73. int DS_CON_VAT::nhap(CON_VAT *c)
74. {
75. if (so_con_vat==max_so_con_vat)
76. return 0;
77. int i=0;
78. while (h[i]!=NULL) ++i;
79. h[i]=c;
80. so_con_vat++ ;
81. return (i+1);
82. }
83. CON_VAT* DS_CON_VAT::xuat(int n)
84. {
85. if (n<1 || n > max_so_con_vat)
86. return NULL ;
87. --n ;
88. if (h[n])
89. {
90. CON_VAT *c = h[n];
91. h[n]=NULL;/*----------------------???---------------------*/
92. so_con_vat-- ;
93. return c;
94. }
95. else
96. return NULL;
97. }
98. void DS_CON_VAT::thong_ke()
99. {
100. if (so_con_vat)
101. {
102. cout << ""\n"" ;
103. for (int i=0; i<max_so_con_vat; ++i)
104. if (h[i])
105. h[i]->xung_ten();
106. }
107. }
108. CON_CHO c1(""MUC"");
109. CON_CHO c2(""VEN"");
110. CON_CHO c3(""LAI"");
111. CON_CHO c4(""NHAT"");
112. CON_CHO c5(""BONG"");
113. CON_MEO m1(""MUOP"");
114. CON_MEO m2(""DEN"");
115. CON_MEO m3(""TRANG"");
116. CON_MEO m4(""TAM THE"");
117. CON_MEO m5(""VANG"");
118. DS_CON_VAT d(20);
119. int main()
120. {
121. //clrscr();
122. d.nhap(&c1);
123. int im2 = d.nhap(&m2);
124. d.nhap(&c3);
125. d.nhap(&m1);
126. int ic4 = d.nhap(&c4);
127. d.nhap(&c5);
128. d.nhap(&m5);
129. d.nhap(&c2);
130. d.nhap(&m3);
131. d.thong_ke();
132. d.xuat(im2);
133. d.xuat(ic4);
134. d.thong_ke();
135. //getch();
136. }";
RegexOptions options = RegexOptions.Multiline;
Regex regex = new Regex(pattern, options);
string result = regex.Replace(input, substitution);
}
}
Please keep in mind that these code samples are automatically generated and are not guaranteed to work. If you find any syntax errors, feel free to submit a bug report. For a full regex reference for C#, please visit: https://msdn.microsoft.com/en-us/library/system.text.regularexpressions.regex(v=vs.110).aspx