On 8/27/2021 8:53 PM, Pablo Rodriguez via ntg-context wrote:
Dear list,
I have the following sample:
\starttext
\startluacode
url = "../a/b/cb/ce.b/ca.b/c/dabc.pdf"
context(url)
context("\\\\0 ok. " .. url:match "^(.*).pdf$") -- name and path
context("\\\\1. " .. url:match "^(.*).+$") -- path
context("\\\\2. " .. url:match"[^/]+[.$]") -- name
context("\\\\3 ok. " .. url:match "[^.]+$") -- extension
\stopluacode
\stoptext
How can I get that match for #1 ends in the last slash (including it
"../a/b/cb/ce.b/ca.b/c/") and match for #2 ends in the last period
(excluding it, "dabc")?
it really helps to read the cld manual (or look into l-* files) as there
are plenty of efficient helpers for these things
local s = "./a/b/cb/ce.b/ca.b/c/dabc.pdf"
print(file.pathpart(s))
print(file.nameonly(s))
print(file.basename(s))
print(file.suffix(s))
print(file.replacesuffix(s,"tmp"))
-----------------------------------------------------------------
Hans Hagen | PRAGMA ADE
Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
tel: 038 477 53 69 | www.pragma-ade.nl | www.pragma-pod.nl
-----------------------------------------------------------------
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the
Wiki!
maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage : http://www.pragma-ade.nl / http://context.aanhet.net
archive : https://bitbucket.org/phg/context-mirror/commits/
wiki : http://contextgarden.net
___________________________________________________________________________________