global lpeg
methods
lpeg.UP
😱 Types incomplete or incorrect? 🙏 Please contribute!
lpeg.UR
😱 Types incomplete or incorrect? 🙏 Please contribute!
lpeg.US
😱 Types incomplete or incorrect? 🙏 Please contribute!
lpeg.afterprefix
Reference:
- Corresponding Lua source code: lualibs-lpeg.lua#L616-L624
😱 Types incomplete or incorrect? 🙏 Please contribute!
lpeg.anywhere
Reference:
- Corresponding Lua source code: lualibs-lpeg.lua#L302-L304
- ConTeXt wiki: ConTeXt and Lua programming/Extensions to the Lua IO library/String manipulation
😱 Types incomplete or incorrect? 🙏 Please contribute!
lpeg.append
Reference:
- Corresponding Lua source code: lualibs-lpeg.lua#L715-L783
😱 Types incomplete or incorrect? 🙏 Please contribute!
lpeg.balancer
Reference:
- Corresponding Lua source code: lualibs-lpeg.lua#L626-L629
😱 Types incomplete or incorrect? 🙏 Please contribute!
lpeg.beforesuffix
Reference:
- Corresponding Lua source code: lualibs-lpeg.lua#L606-L614
😱 Types incomplete or incorrect? 🙏 Please contribute!
lpeg.containsws
Reference:
- Corresponding Lua source code: lualibs-lpeg.lua#L1185-L1194
😱 Types incomplete or incorrect? 🙏 Please contribute!
lpeg.counter
Reference:
- Corresponding Lua source code: lualibs-lpeg.lua#L652-L662
😱 Types incomplete or incorrect? 🙏 Please contribute!
lpeg.endstripper
Reference:
- Corresponding Lua source code: lualibs-lpeg.lua#L501-L503
😱 Types incomplete or incorrect? 🙏 Please contribute!
lpeg.finder
Reference:
- Corresponding Lua source code: lualibs-lpeg.lua#L548-L576
😱 Types incomplete or incorrect? 🙏 Please contribute!
lpeg.frontstripper
Reference:
- Corresponding Lua source code: lualibs-lpeg.lua#L497-L499
😱 Types incomplete or incorrect? 🙏 Please contribute!
lpeg.instringchecker
Reference:
- Corresponding Lua source code: lualibs-lpeg.lua#L308-L313
😱 Types incomplete or incorrect? 🙏 Please contribute!
lpeg.is_lpeg
Reference:
- Corresponding Lua source code: lualibs-lpeg.lua#L675-L677
😱 Types incomplete or incorrect? 🙏 Please contribute!
lpeg.oneof
Reference:
- Corresponding Lua source code: lualibs-lpeg.lua#L679-L689
😱 Types incomplete or incorrect? 🙏 Please contribute!
lpeg.pcode
😱 Types incomplete or incorrect? 🙏 Please contribute!
lpeg.print
Reference:
- Corresponding Lua source code: lualibs-lpeg.lua#L44
😱 Types incomplete or incorrect? 🙏 Please contribute!
lpeg.ptree
😱 Types incomplete or incorrect? 🙏 Please contribute!
lpeg.setutfcasers
Reference:
- Corresponding Lua source code: lualibs-lpeg.lua#L846-L849
😱 Types incomplete or incorrect? 🙏 Please contribute!
lpeg.splitter
Reference:
- Corresponding Lua source code: lualibs-lpeg.lua#L323-L329
- ConTeXt wiki: ConTeXt and Lua programming/Extensions to the Lua IO library/String manipulation
😱 Types incomplete or incorrect? 🙏 Please contribute!
lpeg.splitat
Return a pattern that produces a list of substrings delimited by delimiter (which can be a pattern or a string).
The optional boolean single determines whether the string should be split only at the first match.
Example:
local str = [[
Number twenty-three. The shin.
Number twenty-four. Reginald Maudling's shin.
Number twenty-five. The brain.
Number twenty-six. Magaret Thatcher's brain.
Number twenty-seven. More naughty bits.
]]
local t = { lpeg.splitat("Number", false):match(str) }
for n, element in pairs(t) do
element = element == "" and element .. "\n" or element
io.write(n .. ": " .. element)
end
Reference:
lpeg.firstofsplit
Return a pattern that matches the substring until the first occurrence of separator
Example:
local str =
"menu = spam, spam, spam, spam, spam, baked beans, spam, spam and spam"
print(lpeg.firstofsplit(" = "):match(str))
Reference:
- Corresponding Lua source code: lualibs-lpeg.lua#L584-L592
- ConTeXt wiki: ConTeXt and Lua programming/Extensions to the Lua IO library/String manipulation
lpeg.secondofsplit
Match the whole rest after that regardless of any further occurrences of separator.
Example:
local str =
"menu = spam, spam, spam, spam, spam, baked beans, spam, spam and spam"
print(lpeg.secondofsplit(" = "):match(str))
Reference:
- Corresponding Lua source code: lualibs-lpeg.lua#L594-L602
- ConTeXt wiki: ConTeXt and Lua programming/Extensions to the Lua IO library/String manipulation
lpeg.split
Reference:
- Corresponding Lua source code: lualibs-lpeg.lua#L344-L359
😱 Types incomplete or incorrect? 🙏 Please contribute!
lpeg.checkedsplit
Reference:
- Corresponding Lua source code: lualibs-lpeg.lua#L428-L437
😱 Types incomplete or incorrect? 🙏 Please contribute!
lpeg.stripper
Return a pattern that removes either, if the argument is a string, all occurrences of every character of that string or, if the argument is a pattern, all occurrences of that pattern.
Example:
local str =
"A dromedary has one hump and a camel has a refreshment car, buffet, and ticket collector."
print(lpeg.stripper("aeiou"):match(str))
print(lpeg.stripper(lpeg.P("camel ")):match(str))
Reference:
- Corresponding Lua source code: lualibs-lpeg.lua#L469-L480
- ConTeXt wiki: ConTeXt and Lua programming/Extensions to the Lua IO library/String manipulation
@see lpeg.keeper
lpeg.keeper
Remove anything but the string or pattern respectively. Note: string.keeper
does not seem to work as expected with patterns consisting of more than one byte, e.g. lpeg.P("camel").
Reference:
- Corresponding Lua source code: lualibs-lpeg.lua#L484-L495
@see lpeg.stripper
lpeg.replacer
Returns a pattern that substitutes any first elements of a given pair by its second element.
The latter can be a string, a hashtable, or a function (whatever fits with lpeg.Cs).
Note: Choose the order of elements in table with care. Due to LPEG's matching the leftmost element of disjunction first it might turn out to be as crucial as in the following example:
Example:
local str = "Luxury Yacht"
local rep = {
[1] = { "Luxury", "Throatwobbler" },
[2] = { "Yacht", "Mangrove" },
}
print(
"My name is spelled “"
.. str
.. "”, but it's pronounced “"
.. lpeg.replacer(rep):match(str)
.. "”."
)
str = "aaababaaba"
local rep1 = {
{ "a", "x" },
{ "aa", "y" },
}
local rep2 = {
{ "aa", "y" },
{ "a", "x" },
}
print(lpeg.replacer(rep1):match(str))
print(lpeg.replacer(rep2):match(str))
Reference:
- Corresponding Lua source code: lualibs-lpeg.lua#L510-L543
- ConTeXt wiki: ConTeXt and Lua programming/Extensions to the Lua IO library/String manipulation
lpeg.times
Reference:
- Corresponding Lua source code: lualibs-lpeg.lua#L1068-L1070
😱 Types incomplete or incorrect? 🙏 Please contribute!
lpeg.tsplitat
Reference:
- Corresponding Lua source code: lualibs-lpeg.lua#L361-L368
😱 Types incomplete or incorrect? 🙏 Please contribute!
lpeg.tsplitter
Reference:
- Corresponding Lua source code: lualibs-lpeg.lua#L331-L337
😱 Types incomplete or incorrect? 🙏 Please contribute!
lpeg.utfchartabletopattern
Reference:
- Corresponding Lua source code: lualibs-lpeg.lua#L895-L971
😱 Types incomplete or incorrect? 🙏 Please contribute!
lpeg.utfreplacer
Reference:
- Corresponding Lua source code: lualibs-lpeg.lua#L975-L980
😱 Types incomplete or incorrect? 🙏 Please contribute!