﻿---
title: Painless regex unrestricted
description: Describes what AutoOps detects and surfaces with the Painless regex unrestricted insight: Painless regular expressions are fully enabled (`script.painless.regex.enabled` is true).
url: https://docs-v3-preview.elastic.dev/elastic/autoops-insights/tree/main/elasticsearch/painless_regex_unrestricted
products:
  - Elastic Cloud Enterprise
  - Elastic Cloud Hosted
  - Elastic Cloud on Kubernetes
  - Elasticsearch
applies_to:
  - Elastic Cloud Hosted: Generally available
  - Elastic Cloud on Kubernetes: Generally available
  - Elastic Cloud Enterprise: Generally available
  - Self-managed Elastic deployments: Generally available
---

# Painless regex unrestricted
Painless regular expressions are fully enabled (`script.painless.regex.enabled` is true). Some patterns are extremely CPU- and memory-heavy.
<note>
  For a complete list of insights, refer to [AutoOps insights](https://docs-v3-preview.elastic.dev/elastic/autoops-insights/tree/main/elasticsearch).
</note>


## Insight details


| Field     | Value                        |
|-----------|------------------------------|
| Component | Elasticsearch                |
| Severity  | Medium                       |
| Scope     | Cluster                      |
| Domains   | performance, security-safety |


## Example: What you might see in AutoOps

The following is an example of what you might see when this insight is triggered. Real insights use live data and links from your deployment or cluster.

### Painless regex is fully enabled


#### What was detected

`script.painless.regex.enabled` is true. Regular expressions in Painless run without the complexity limit.

#### Recommendations

<note>
  AutoOps shows different recommendations depending on how their conditions match your deployment or cluster.
</note>

<dropdown title="Limit Painless regex complexity">
  **Condition**: Always shown for this insight.Set `script.painless.regex.enabled` to `limited` unless you have a measured need for unrestricted regex. Use `false` only if no Painless regex should run. Add the setting in `elasticsearch.yml` on every node, then restart each node.
  ```yaml
  script.painless.regex.enabled: limited
  ```

  <note>
    `true` removes the complexity cap. Elasticsearch default is `limited`.
  </note>
</dropdown>


#### Background and impact

Regular expressions in Painless can search or transform text with flexible patterns. Some expressions consume large amounts of CPU and memory and can stall ingest, update-by-query, or search on the node.
Elasticsearch turns off unbounded regex by default. The `limited` value allows regex with a complexity cap. `true` removes that cap.
Use unrestricted regex only when you have a measured need. Prefer `limited` when you need Painless regex at all.

## Guide

[Regular expressions](https://docs-v3-preview.elastic.dev/elastic/elasticsearch/tree/main/reference/scripting-languages/painless/painless-walkthrough-regular-expressions)