bp/Lua/README.md

16 lines
510 B
Markdown
Raw Normal View History

2021-09-22 23:51:34 -07:00
# Lua Bindings
2021-09-24 23:58:23 -07:00
This directory contains Lua bindings for bp. The bindings are intended to be roughly
equivalent in usefulness to LPEG, but with a smaller codebase.
2021-09-22 23:51:34 -07:00
## API
```lua
local bp = require("bp")
2021-09-24 22:57:39 -07:00
local m, i, len = bp.match("like finding a needle in a haystack", '"n" @Es=+`e "dle"')
--> {[0]="needle", Es={[0]="ee"}}
--> tostring(m) == "needle", tostring(m.Es) == "ee"
2021-09-22 23:51:34 -07:00
local replaced = bp.match("like finding a needle in a haystack", '"n" +`e "dle"', "cat")
2021-09-24 22:57:39 -07:00
--> "like finding a cat in a haystack"
2021-09-22 23:51:34 -07:00
```