Thread: Regular Expression
-
February 14th, 2020, 03:54 #1
Regular Expression
Are not my strength beyond the simple ones I use regularly in grep and vi.
Which "flavor" of expressions are used in Lua/FG?
I used to plug in really complex expressions into various online "decomposers" like regexpr.com (forgot exact name) to show graphically what it is doing.
I suspect, glancing at https://riptutorial.com/lua/example/...ttern-matching after a search that Lua is not using a "standard" syntax of RE like pcre or grep(not sure which that is) or any of the others.
Figure if it has a name I could search for a translator to save my looking at them char at a time... cos yes, I like to avoid the effort
-
February 14th, 2020, 04:06 #2
I mean for example if I tried to input
^align%s*%(([^)]+)%)$
on
https://regexper.com/#%5Ealign%25s*%...2B%29%25%29%24
it would translate it wrong:
Screen Shot 2020-02-13 at 11.01.21 PM.png
Instead of:
<starts with>align<followed by 0..n spaces then>(<then it saves in a "group" 1..n characters until it sees the first>)<which should be the end of the line>
(unsure if that means it would not stop at first ")" if later there was a ")" at end of line..., e.g. align (1)111) -> would that NOT match or match the group as "1)111"? )
-
February 14th, 2020, 04:25 #3
Lua doesn't use regex, it uses it's own "pattern matching" which is nowhere near as comprehensive as regex.
Start here to read up on it and here for pattern matching functions.
-
February 14th, 2020, 04:28 #4
Supreme Deity
- Join Date
- Mar 2007
- Posts
- 20,412
Lua uses its own pattern matching engine.
https://www.lua.org/pil/20.2.html
Here’s why:
https://stackoverflow.com/questions/...192354#6192354
I occasionally look for a pattern tester online; but haven’t found one that I have kept.
Regards,
JPG
-
February 14th, 2020, 04:35 #5
Thanks, yeah, I just started looking at the patterns and realized what I thought they said was wrong (used to other regex) so then found some Lua reg expression info and was "oooo, I see..." and hoped there was a good scanner for it to avoid noob mistakes in my interpretations in case I used one of them as basis for new match string later.
I'll just have to be careful then
Thread Information
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks