# Searching list of words not working on pdf viewer

**URL:** <https://pdfjs.community/t/searching-list-of-words-not-working-on-pdf-viewer/381>\
**Category:** Technical Support\
**Created:** [November 4, 2020, 6:40am UTC](https://pdfjs.community/t/searching-list-of-words-not-working-on-pdf-viewer/381 "2020-11-04T06:40:49Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![himani.sharma](https://avatars.discourse-cdn.com/v4/letter/h/e47774/32.png) [@himani.sharma](https://pdfjs.community/u/himani.sharma)\
**Post date:** [November 4, 2020, 6:40am UTC](https://pdfjs.community/t/searching-list-of-words-not-working-on-pdf-viewer/381/1 "2020-11-04T06:40:49Z")

</div>

**PDF.js Express Version**

**Detailed description of issue**  
Error - Unhandled Promise rejection: TypeError: e.split is not a function

**Expected behaviour**  
Should highlight all the words matching in the pdf.

**Does your issue happen with every document, or just one?**  
{Answer here}

**Link to document**  
{Provide a link to the document in question if possible}

**Code snippet**  
let arr = [‘RAS’, ‘Cable’, ‘92780’]  
var regexFromMyArray = new RegExp(arr.join("|"), ‘g’);  
console.log(‘regex…’, regexFromMyArray)  
instance.docViewer.setSearchHighlightColors({  
searchResult: ‘rgba(0, 255, 0, 0.5)’,  
activeSearchResult: ‘rgba(0, 255, 0, 0.5)’  
});  
instance.searchText(regexFromMyArray)

---

<div class="post-metadata">

**Author:** ![Logan](https://yyz1.discourse-cdn.com/flex031/user_avatar/pdfjs.community/logan/32/13_2.png) [@Logan](https://pdfjs.community/u/Logan)\
**Post date:** [November 4, 2020, 5:18pm UTC](https://pdfjs.community/t/searching-list-of-words-not-working-on-pdf-viewer/381/2 "2020-11-04T17:18:02Z")

</div>

Hey there!

Sorry, I should have been a bit more specific in my last comment.

You’ll probably want to do something like this:

```javascript
let arr = [‘RAS’, ‘Cable’, ‘92780’]
var regexFromMyArray = arr.join("|");

instance.docViewer.setSearchHighlightColors({
   searchResult: ‘rgba(0, 255, 0, 0.5)’,
   activeSearchResult: ‘rgba(0, 255, 0, 0.5)’
});
instance.searchTextFull(regexFromMyArray, { regex: true })

```

The things I changed here was using `searchTextFull` instead of just `searchText`, and using a string representation of the regex rather than an actual regex.

I hope this helps!

Thanks,  
Logan
