Skip to content

Positive Lookaheads

· 1 min read · regex · tools

Find expression xx where expression yy follows:-

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

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

Regex Breakdown

Paloma Picasso // => true
Maya Picasso // => true
Steve Ross // => false

To experiment, navigate to the Regex101 sandbox 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

Thanks for reading. RSS feed · LinkedIn

More writings

  1. Know When to Step In
  2. How to write an eval for your agent
  3. Your agent is probably using git worktrees
  4. So Much for O(1)
  5. We Might All Be AI Engineers Now
  6. The Hardest Bug I Ever Fixed Wasn't in Code
  7. Why I Switched to Podman (and Why You Might Too)
  8. The World is Stochastic
  9. Debugging a running Java app in Docker
  10. Why is it UTC and not CUT?
  11. Deep prop drilling in ReactJS
  12. Eigenvectors
  13. Java's fork/join framework
  14. TypeScript's omit and pick
  15. JavaScript's new immutable array methods
  16. Integrating JUnit 5 in Maven projects
  17. My take on ChatGPT and prompt engineering
  18. Declarative events in ReactJS
  19. Functors
  20. Fast forward videos with ffmpeg
  21. Rotate y-axis of a 2D vector
  22. Synchronizing time
  23. Vector rotation
  24. Sed find and replace
  25. Asgardeo try it application
  26. Flatten error constraints
  27. Good Git commit messages
  28. Asgardeo JIT user provisioning
  29. Monotonic Arrays
  30. How GOROOT and GOPATH works
  31. Two summation