I have some magnet links being submitted as string in Lua. These magnets normally are of the format:
magnet:?xt=<hashing>&xl=<size>&dn=<name>
but with differences in the clients the magnets can also be generated as:
magnet:?xl=<size>&xt=<hashing>&dn=<name>
From this type of string, I want to fetch the data after xl=(which is pure number) and after xt= which consists of %w and :(where %w is alphanumeric match).
Currently I am using two separate statements to fetch these values. Can this be achieved in a single statement/string.find()?
sInput = "magnet:?xt=urn:tree:tiger:ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890ABC&xl=1234567890123456789&dn=This+Is+The+Name+Of+File.EXT"
local _, _, sHash = sInput:find( "xt=([%w%:]+)" )
local _, _, iSize = sInput:find( "xl=(%d+)" )