Hi Team,
We are trying to work out how to detect certain costumer numbers in word documents.
For that we have come up with the following regex:
@"(Customer Number|Customer No|Customer #|Customer#|CustomerID|Customerno|customernumber)\W*\d{9}\b"
which we try to use like this
int r = wordsDocument.Range.Replace(new Regex(@"(Customer Number|Customer No|Customer #|Customer#|CustomerID|Customerno|customernumber)\W*\d{9}\b", RegexOptions.None), “REPLACED”);
With RegexOptions.None this manages to locate the data across multiple lines even multiple cells of the same table.
Selection_113.png (688 Bytes)
Selection_114.png (11.7 KB)
However as soon as we add RegexOptions.Multiline as follows:
int r = wordsDocument.Range.Replace(new Regex(@"(Customer Number|Customer No|Customer #|Customer#|CustomerID|Customerno|customernumber)\W*\d{9}\b", RegexOptions.Multiline), “REPLACED”);
Aspose.Words does not detect data instances any more.
It is quite confusing why Multiline affects this regex, because it is supposed to change the behavior of regexes with ^ $ characters only.
Please help us understand this. Thank you.
FYI, I’ve attached an example application to demonstrate the above.
CustomerNumberDetectionInWord.zip (325.9 KB)