Düzenli İfade Kullanarak Bir Çalışma Kitabındaki Metni Değiştirme

Contents
[ ]

Aspose.Cells, düzenli bir ifade kullanarak bir çalışma kitabındaki metni değiştirme özelliğini sağlar. Bu için API, RegexKey özelliğini içeren ReplaceOptions sınıfını sağlar. RegexKey ayarını true olarak belirlemek aranan anahtarın düzenli bir ifade olacağını gösterir.

Aşağıdaki kod parçası, örnek excel dosyası kullanılarak RegexKey özelliğinin nasıl kullanılacağını gösterir. Aşağıdaki kod parçası tarafından oluşturulan çıkış dosyası referans için eklenmiştir.

Örnek Kod

// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-Java
// directories
String sourceDir = Utils.Get_SourceDirectory();
String outputDir = Utils.Get_OutputDirectory();
Workbook workbook = new Workbook(sourceDir + "SampleRegexReplace.xlsx");
ReplaceOptions replace = new ReplaceOptions();
replace.setCaseSensitive(false);
replace.setMatchEntireCellContents(false);
// Set to true to indicate that the searched key is regex
replace.setRegexKey(true);
workbook.replace("\\bKIM\\b", "^^^TIM^^^", replace);
workbook.save(outputDir + "RegexReplace_out.xlsx");