Düzenli İfade Kullanarak Bir Çalışma Kitabındaki Metni Değiştirme
Aspose.Cells, Düzenli İfade kullanarak bir çalışma kitabındaki metni değiştirme özelliği sağlar. Bunun için API, ReplaceOptions sınıfının RegexKey özelliğini sağlar. RegexKey true olarak ayarlandığında, aranan anahtarın bir düzenli ifade olduğunu belirtir.
Aşağıdaki kod parçacığı, RegexKey özelliğinin kullanımını gösterir ve örnek excel dosyası kullanır. Aşağıdaki kod parçacığı tarafından oluşturulan çıkış dosyası referans için ekte bulunmaktadır.
Örnek Kod
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET | |
//Source directory | |
string sourceDir = RunExamples.Get_SourceDirectory(); | |
//Output directory | |
string outputDir = RunExamples.Get_OutputDirectory(); | |
Workbook workbook = new Workbook(sourceDir + "SampleRegexReplace.xlsx"); | |
ReplaceOptions replace = new ReplaceOptions(); | |
replace.CaseSensitive = false; | |
replace.MatchEntireCellContents = false; | |
// Set to true to indicate that the searched key is regex | |
replace.RegexKey = true; | |
workbook.Replace("\\bKIM\\b", "^^^TIM^^^", replace); | |
workbook.Save(outputDir + "RegexReplace_out.xlsx"); |