# Positive Lookaheads

> Oh, you're looking for something? Well, I'm looking for something too.

March 7, 2023 · 1 min read · https://yasint.dev/positive-lookaheads/
Tags: regex, tools

---

Find expression $$x$$ where expression $$y$$ follows:-

Suppose you need to match all the first names ending with last name _Picasso_.
You could write the following pattern to solve it.

```regexp hideLineNums
([a-zA-Z ]+)(?=Picasso)
```

![Regex Breakdown](./regex-breakdown.png)

```txt hideLang
Paloma Picasso // => true
Maya Picasso // => true
Steve Ross // => false
```

To experiment, navigate to the [Regex101 sandbox](https://regex101.com/r/av8c3o/1)
I've created. This RegEx needs a backtracking engine (PCRE, JavaScript, Python, Java, .NET). Automata-based engines like RE2, Go's regexp and Rust's regex crate don't support lookaheads.

### Reading list

- [Regular Expressions with Lookahead (Berglund et al., 2021)](https://www.diva-portal.org/smash/get/diva2:1641657/FULLTEXT01.pdf)
- [NFA vs DFA by Daniel Bazaco](https://www.abstractsyntaxseed.com/blog/regex-engine/nfa-vs-dfa)
