Search Config Question: Dealing with (lack of) spaces in OCR text

I’m using version 8.7.4, installed manually on an existing website. The PDFs on this site are historical documents with OCR’d text that generally does not have spaces between words. So searching for a phrase basically never works. See example below.

Single word search

Note the OCR text preview

Is there a configuration that can help with this issue (e.g. by turning spaces into an optional wildcard)? I know that the core PDFjs viewer, as implemented in Firefox, does not have this limitation, so maybe there’s a well-known way to deal with this.

Below is my code, which is pretty close to default.

  const pdf = document.querySelector("[data-pdf]");
      path: 'xxx',
      licenseKey: "xxx",
      initialDoc: pdf.dataset.pdf,
      disabledElements: [
    }, document.getElementById('viewer')).then(instance => {
      const docViewer = instance.docViewer;
      const annotManager = instance.annotManager;


NOTE: Continuing with some additional screenshots below (new users can only include one file upload per post).

Searching a phrase w/o spaces

Note the OCR text preview

Searching a phrase with spaces

Same document search in Firefox

Works as expected in PDFjs, as implemented in Firefox

Hi there,

You would have to implement your own regex search.

Here is a link to a useful guide on searching: Basic searching | Documentation

Thank you.

Best Regards,
Darian Chen