mirror of
https://github.com/brues-code/pfUI.git
synced 2026-10-01 19:30:00 +00:00
api: unify pattern conversion for gfind
This commit is contained in:
+20
@@ -85,6 +85,26 @@ function pfUI.api.round(input, places)
|
||||
end
|
||||
end
|
||||
|
||||
-- [ SanitizePattern ]
|
||||
-- Sanitizes and convert patterns into gfind compatible ones.
|
||||
-- 'pattern' [string] unformatted pattern
|
||||
-- returns: [string] simplified gfind compatible pattern
|
||||
function SanitizePattern(pattern)
|
||||
-- escape brackets
|
||||
pattern = gsub(pattern, "%(", "%%(")
|
||||
pattern = gsub(pattern, "%)", "%%)")
|
||||
|
||||
-- remove bad capture indexes
|
||||
pattern = gsub(pattern, "%d%$s","s") -- %1$s to %s
|
||||
pattern = gsub(pattern, "%ds","s") -- %2s to %s
|
||||
|
||||
-- add capture to all findings
|
||||
pattern = gsub(pattern, "%%s", "(.+)")
|
||||
pattern = gsub(pattern, "%%d", "(%%d+)")
|
||||
|
||||
return pattern
|
||||
end
|
||||
|
||||
-- [ GetItemLinkByName ]
|
||||
-- Returns an itemLink for the given itemname
|
||||
-- 'name' [string] name of the item
|
||||
|
||||
Reference in New Issue
Block a user