我正在尝试删除停留在删除中的C代码的注释和引号
/* qwe*qew */
我的正则表达式为...|(\\/\\*[^\\*\\/]*\\*\\/)|...
,输出为:/* qwe*qwe */
我意识到这是因为:[^\\*\\/]*
它分别查找*和/。
有什么想法要删除它吗?
答案 0 :(得分:0)
您可以使用
[HttpGet] public IActionResult Excel () {
using (ExcelEngine excelEngine = new ExcelEngine ()) {
//Instantiate the Excel application object
IApplication application = excelEngine.Excel;
//Assigns default application version
application.DefaultVersion = ExcelVersion.Excel2013;
//A new workbook is created equivalent to creating a new workbook in Excel
//Create a workbook with 1 worksheet
IWorkbook workbook = application.Workbooks.Create (1);
//Access a worksheet from workbook
IWorksheet worksheet = workbook.Worksheets[0];
//Adding text data
worksheet.Range["A1"].Text = "Month";
worksheet.Range["B1"].Text = "Sales";
worksheet.Range["A6"].Text = "Total";
//Adding DateTime data
worksheet.Range["A2"].DateTime = new DateTime (2015, 1, 10);
worksheet.Range["A3"].DateTime = new DateTime (2015, 2, 10);
worksheet.Range["A4"].DateTime = new DateTime (2015, 3, 10);
//Applying number format for date value cells A2 to A4
worksheet.Range["A2:A4"].NumberFormat = "mmmm, yyyy";
//Auto-size the first column to fit the content
worksheet.AutofitColumn (1);
//Adding numeric data
worksheet.Range["B2"].Number = 68878;
worksheet.Range["B3"].Number = 71550;
worksheet.Range["B4"].Number = 72808;
//Adding formula
worksheet.Range["B6"].Formula = "SUM(B2:B4)";
var name = Guid.NewGuid() + ".xlsx";
//Inserting image
//Saving the workbook to disk in XLSX format
FileStream fileStream = new FileStream (name, FileMode.Create, FileAccess.ReadWrite); // Copy file stream to MemoryStream.
MemoryStream memoryStream = new MemoryStream ();
fileStream.CopyTo (memoryStream);
// Gets byte array from memory stream of file.
byte[] temp = memoryStream.ToArray ();
excelEngine.Dispose();
return File (temp, "application/ms-excel", name);
}
}
\/\*[\w\W]*?\*\/
-匹配\/\*
/*
-匹配任何内容(惰性模式)