Lua Patterns Viewer
A tool for inspecting, analyzing and learning Lua patterns. Inspired by https://regexr.com/ and https://regex101.com/. Any help, feedback, suggestions, criticism are welcome.
Category: JavaScript / Miscellaneous |
Watchers: 1 |
Star: 11 |
Fork: 0 |
Last update: Oct 3, 2021 |
A tool for inspecting, analyzing and learning Lua patterns. Inspired by https://regexr.com/ and https://regex101.com/. Any help, feedback, suggestions, criticism are welcome.
IDs should be unique within an HTML document, so they are poorly suited for marking the type of a subpattern.
Handling the compact view of the descriptions can be done in CSS instead, which makes it easier to handle as it only needs one class to be toggled in the DOM.
Hey @GitSparTV, This tries to implement #3.
I decided to go with Vanilla JS as you were using it already, I tried to use Rich Text Editor like CKEditor but could not make it work as RegEx101.
So what I did was just get input from a textfield, parse it and display it in a p tag.
In the end it looks like this:
ps. I tried to follow the color scheme you have on the site.
The logic is pretty simple, just some Ifs and adding span tags with certain classes. You can keep the code as it is and improve it if you want, or I can change it for you.
I did not inserted it on the main page because I don't know how would you like to display it.
Let me know what you think. Thank you for considering this.
Should be simple to embed fengari (or just rip the code out of it) to run the given lua pattern on a blob of text.
The position capture incorrectly consumes the following token. See "ello" in the following example:
Possible suspect:
https://github.com/GitSparTV/lua-patterns/blob/e23047628db8f5b8d544acb1f37af4b31a65d709/pm.js#L492
The set for %p
and %P
doesn't have stuff like @
, ?
, <
, etc.
You can grab all the punctuation symbols using the following code (credits: Colonel Thirty Two):
for i = 0, 255 do
if string.match(string.char(i), "%p") then
io.write(string.char(i))
end
end
io.write("\n")
Tested on 5.1, 5.2, 5.4, and JIT. Results are the same for each version.
This tool looks really cool! It reminds me of https://regexper.com/ (which is also open-source) - so I thought I'd suggest a railroad diagram, so it would make complex patterns easier to quickly understand :-)
Useful for spotting unescaped characters, spotting unclosed parentheses, etc. In lua's case, it might help the user identify differences between regular regex and lua regex.
Screenshot from a website that does this (https://regex101.com):
Later, could add a hover tooltip giving more info for each color.