Analyzing your prompt, please hold on...
An error occurred while retrieving the results. Please refresh the page and try again.
Aspose.Cells provides a feature to replace text in a workbook using a regular expression. For this, the API provides the GetRegexKey() property of the ReplaceOptions class. Setting the GetRegexKey() to true indicates that the searched key will be a regular expression.
The following code snippet demonstrates the use of the GetRegexKey() property with the sample Excel file (101089318.xlsx). The output file generated by the code snippet is attached for reference.
#include <iostream>
#include "Aspose.Cells.h"
using namespace Aspose::Cells;
int main()
{
Aspose::Cells::Startup();
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-C
// Source directory path
U16String sourceDir = u"..\\Data\\01_SourceDirectory\\";
// Output directory path
U16String outputDir = u"..\\Data\\02_OutputDirectory\\";
// Create workbook from the input file
Workbook workbook(sourceDir + u"SampleRegexReplace.xlsx");
// Create replace options
ReplaceOptions replace;
replace.SetCaseSensitive(false);
replace.SetMatchEntireCellContents(false);
// Set to true to indicate that the searched key is a regular expression
replace.SetRegexKey(true);
// Perform the regex replace operation
workbook.Replace(u"\\bKIM\\b", u"^^^TIM^^^", replace);
// Save the modified workbook
workbook.Save(outputDir + u"RegexReplace_out.xlsx");
std::cout << "Regex replace operation completed successfully!" << std::endl;
Aspose::Cells::Cleanup();
}
Analyzing your prompt, please hold on...
An error occurred while retrieving the results. Please refresh the page and try again.