# Improve Regex highlighting \(\#28183\) · gitcafe/zed

[View on GitCafe](https://git.cafe/gitcafe/zed/commit/f97546b6efc4e03e0e093a7535d21e52a4140783)

Repository: [gitcafe/zed](https://git.cafe/gitcafe/zed)

Visibility: public

Requested revision: f97546b6efc4e03e0e093a7535d21e52a4140783

Requested commit: f97546b6efc4e03e0e093a7535d21e52a4140783

Commit: f97546b6efc4e03e0e093a7535d21e52a4140783

Tree: 6cce283c0cf90532fbd37092d429685d1e991450

Author: chbk

Committer: GitHub

## Message

````
Improve Regex highlighting (#28183)


| Zed 0.180.2 | With this PR |
| --- | --- |
|
![Image](https://github.com/user-attachments/assets/e840bd81-25ff-4c7a-af03-bac6db11f910)
|
![Image](https://github.com/user-attachments/assets/3fd58164-8992-44e1-be01-8c6d70f9587d)
|

```js
match = "424242"
regex = /(42)+?\d{2}\1/g
```

- `/`: `operator` -> `string.regex` (like `"` for regex strings)
- `+?`: `operator.regex`
- `\d`: `string.escape` -> `string.escape.regex`
- `\1`: `keyword.operator.regex` (backreference)
- `/g`: `keyword.regex` -> `keyword.operator.regex`
- `{2}`: `number` -> `number.quantifier.regex`

Release Notes:

  - Improved Regex highlighting
````

## Parents

- [7badd6053ddc0371625fd6fdcb98c50e7f8427c4](https://git.cafe/gitcafe/zed/commit/7badd6053ddc0371625fd6fdcb98c50e7f8427c4?format=markdown)

[Source at this commit](https://git.cafe/gitcafe/zed/tree/f97546b6efc4e03e0e093a7535d21e52a4140783?format=markdown)
