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

Contents
[ ]

Aspose.Cells for Python via .NET, bir çalışma kitabında bulunan metni düzenli ifadeler kullanarak değiştirme özelliği sağlar. Bu amaçla API, ReplaceOptions.regex_key özelliği ve ReplaceOptions sınıfını sağlar. ReplaceOptions.regex_key ayarlandığında, aranılan anahtarın düzenli ifade olacağı anlamına gelir, bunun doğru olması gerekir.

Aşağıdaki kod parçacığı, ReplaceOptions.regex_key ö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

from aspose.cells import ReplaceOptions, Workbook
# For complete examples and data files, please go to https:# github.com/aspose-cells/Aspose.Cells-for-.NET
# Source directory
sourceDir = RunExamples.Get_SourceDirectory()
# Output directory
outputDir = RunExamples.Get_OutputDirectory()
workbook = Workbook(sourceDir + "SampleRegexReplace.xlsx")
replace = ReplaceOptions()
replace.case_sensitive = False
replace.match_entire_cell_contents = False
# Set to true to indicate that the searched key is regex
replace.regex_key = True
workbook.replace("\\bKIM\\b", "^^^TIM^^^", replace)
workbook.save(outputDir + "RegexReplace_out.xlsx")