We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Help with search text in a pdf using RegEx!

I have searched and not really found a RegEx pattern that will pickup any string between “[” and “]”, regardless if the text and/or delimiter spans a line. So far, the RegEx I am using is, “([)(?<=[)(.*?)(?=])(](.|\r\n)?)”. It does not seem to pickup the item embedded in the pdf, but on different lines. I have a sample pdf I can share, but this dialog doesn’t seem to let me share i. I have also included the code fragments pertaining to this:

TextFragmentAbsorber textFragmentAbsorber = new TextFragmentAbsorber(@"([)(?<=[)(.*?)(?=])(](.|\r\n)?)", new TextSearchOptions(true));
List foundStringTokens = new List();
IEnumerator textFragmentsEnumerator = textFragmentAbsorber.TextFragments.GetEnumerator();
while (textFragmentsEnumerator?.MoveNext() ?? false)


Thank you for contacting support.

Please test the regular expression at any online regex tester utility and check if required text is found or not. In case text is matched successfully while testing but Aspose.PDF for .NET API does not find the text then please share source file with us by drag and drop into post editor or clicking the upload button while replying. Otherwise you may redesign or enhance the regex as per your requirements.

Feel free to contact us if you notice any anomaly related to Aspose.PDF for .NET API. We will be glad to assist you accordingly.

I have the code right in this post. Howveer, I do not see a way to share the pdf so you can see what I mean…

I have also tested the pattern on a website and it seemed to work fine. I have read in many posts here how Aspose add /r/n to the end of a line, so I modified my pattern to include this. However, it does not work. This is why I am requesting help. Thank you.


Thank you for elaborating it further.

You can upload any file or a zipped archive by using the upload button in header of the post editor. Please see this screenshot for your kind reference HowToUpload.png. You can also upload a file to any free file sharing server like Dropbox, Google Drive etc and then share its download URL here.