FindAll with RegEx not working as expected

Anyone have issues with DocIO FindAll and RegEx not working as expected.

I had added some "tags" to a Word doc that I want to replace. I have a C# RegEx pattern that I have tested outside of the code and have confirmed that it does find matches. I even simplified the RegEx pattern to something simple and FindAll does not work. FindAll does work if I put just straight text  but I need a relatively complex RegEx pattern to locate my "tags".

My doc includes this text "... ![INCLUDE_IF_TRUE::IncludeNoticeSensitiveData|NOTICE: THIS DOCUMENT CONTAINS SENSITIVE DATA\r\n]!Discovery Level\r\nDiscovery in this case is intended to be conducted under..."

RegEx -> Matches

@"Discovery" -> finds matches

@"\[" -> finds matches

@"!\[" -> Does NOT find matches and it should


My full pattern is not working either:

@"(?:!\[)(\w+)(?:::([^\|]*))?\|(.*?)(?:\]!)"


It does not seem like the RegEx pattern is the issue.



3 Replies

HC Hemalatha Chiranjeevulu Syncfusion Team July 2, 2021 11:16 AM UTC

Hi Andrew,

Thank you for contacting Syncfusion support.

We can reproduce the reported tags (“
!\[“) not find from the Word document which contains RegEx pattern (“(?:!\[)(\w+)(?:::([^\|]*))?\|(.*?)(?:\]!)) in our end, and we suspect it to be a defect. Currently we are validating this issue and we will update you with more details on 6th  July 2021.

Please let us know if you have any other questions.

Regards,
Hemalatha C



AH Andrew Hawes July 2, 2021 02:47 PM UTC

It seems the problem is on my end. I am getting better results now.


My first problem was a stupid mistake where I was making changes to the source document but not saving the changes so I thought the code was searching the test I was seeing in the Word document on my screen but it was searching the saved version which did not have my changes.


The second issue I found was that I was using FindAll which only searches within a paragraph. In my case, my "tags" spanned paragraphs so FindAll would not work. I have to use FindSingleLine (poorly named if you ask me) which spans paragraphs.


Slowly but surely I think I am finding the solution, but it is taking much longer than planned.



HC Hemalatha Chiranjeevulu Syncfusion Team July 5, 2021 06:25 AM UTC

Hi Andrew,

Thank you for your update.

We are glad to know that you have found solution by yourself.

Please let us know if you need any further assistance. We are happy to assist you as always.

Regards,
Hemalatha C


Loader.
Up arrow icon