# Redact PDFs using regex

Nutrient Web SDK allows you to search text matching a regular expression and redact it.

[Try for free](https://www.nutrient.io/sdk/web/getting-started.md)

[Launch demo](https://www.nutrient.io/demo/redaction)

You can use [`instance.createRedactionsBySearch`](https://www.nutrient.io/api/web/NutrientViewer.Instance.html#createRedactionsBySearch) to do this:

```js

await instance.createRedactionsBySearch("J[a-zA-Z]+t", {
  searchType: NutrientViewer.SearchType.REGEX
});

```

The code above will search all the four-letter words in the document and add redaction annotations over them. If you’re happy with the added redaction annotations, you can apply them using [`instance.applyRedactions`](https://www.nutrient.io/api/web/NutrientViewer.Instance.html#applyRedactions). This is an irreversible process.

Keep in mind that each setup uses a different regex syntax:

- **Nutrient Web SDK** — JavaScript (see [Mozilla’s regular expressions](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions))

- **Nutrient Web SDK with Document Engine** — [ICU regular expressions](http://userguide.icu-project.org/strings/regexp), which are derivative of Perl regular expressions
---

## Related pages

- [Redact PDFs using JavaScript tools](/guides/web/redaction/built-in-ui.md)
- [JavaScript PDF redaction library](/guides/web/redaction.md)
- [Automate document redaction with predefined patterns](/guides/web/redaction/preset-patterns.md)
- [Production-safe redaction workflow](/guides/web/redaction/production-safe-workflow.md)
- [Search and redact PDFs using JavaScript](/guides/web/redaction/search-and-redact.md)
- [PDF redaction techniques for your documents](/guides/web/redaction/introduction-to-redaction.md)
- [Programmatically redact PDFs using JavaScript](/guides/web/redaction/programmatically.md)
- [Headless redaction](/guides/web/redaction/headless.md)

