What is the status and USP of the Lua rex extension?

Łukasz Stelmach l.stelmach at samsung.com
Mon Jan 7 10:16:40 UTC 2019


It was <2019-01-05 sob 07:38>, when Tim Landscheidt wrote:
> with Fedora 28's RPM 4.14.2.1, I was looking at
> http://rpm.org/user_doc/lua.html to mangle some strings.  It
> took some experimentation to find that the actually working
> syntax is:
>
> | [tim at passepartout ~]$ rpm --eval '%{lua: local re =
> | rex.newPOSIX("abc"); if re:match("abcdef") then print("Matched")
> | else print("Not matched"); end}'
> | Matched
> | [tim at passepartout ~]$ rpm --eval '%{lua: local re =
> | rex.newPOSIX("abc"); if re:match("acdef") then print("Matched") else
> | print("Not matched"); end}'
> | Not matched
> | [tim at passepartout ~]$
[...]
> | [tim at passepartout ~]$ rpm --eval '%{lua: print(string.match("abcdef", "abc"));}'
> | abc
> | [tim at passepartout ~]$
>
> So what is the status of and advantage to use the rex exten-
> sion over the internal string module?  In Fedora's spec
> files, rex does not seem to be used once, but string quite a
> bit.

string.match[1] does not suport regular expressions but rather its own
syntax. Regular expressions[2][3] are much more powerful tool.

[1] http://lua-users.org/wiki/StringLibraryTutorial
[2] https://en.wikipedia.org/wiki/Regular_expression
[3] https://www.xkcd.com/208/
-- 
Łukasz Stelmach
Samsung R&D Institute Poland
Samsung Electronics
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 487 bytes
Desc: not available
URL: <http://lists.rpm.org/pipermail/rpm-list/attachments/20190107/4ab99498/attachment.asc>


More information about the Rpm-list mailing list