lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


On Sunday, March 01, 2015 10:04:30 AM Pablo Botelho wrote:
> s1 = '/foo/:bar/oof/:rab'
> 
> s2 = '/foo/lua/oof/rocks'
> 
> I would like to produce the following information
> 
> 1) If they match (these two above should match)
> 
> 2) a table holding the values of 's2' in with the corresponding name in 's1'
> In this case we would have: { bar = "lua", rab = "rocks" }

The template you describe is basically a pattern to match the second string. 
Just change each '/:(%w+)' to '/(%%w+)' with gsub. And the same pattern to 
extract the names.

-- 
tom <telliamed@whoopdedo.org>