--- 
canonical: 'https://mwop.net/blog/2024-10-18-lua-regex-escape.html'
title: 'Escaping Regex Characters in Lua'
author: "[Matthew Weier O'Phinney](https://mwop.net)"
created: '2024-10-18T10:56:33-05:00'
updated: '2024-10-18T10:56:33-05:00'
tags:
  - lua
  - til

---
Quick little note mainly for myself: Lua regex is different than PCRE. The big place it differs is in where you escape pattern matching characters (e.g. `.`, `?`, `+`, etc.). In PCRE, you escape these with a leading backslash (e.g., `\.`, `\?`, `\+`). However, with Lua, you use the `%` character: `%.`, `%?`, `%+`.



