LibDeformat-3.0

Whether this project is out of date or its author marked it as abandoned, this project is no longer maintained.

If you wish to take this project over, please report it and state your intentions.

This library will convert a fully-formatted text string to its original arguments given a format string.

It is essentially the opposite of string.format.

localLibDeformat=LibStub("LibDeformat-3.0")LibDeformat("Hello, friend","Hello, %s")=>"friend"LibDeformat("Hello, friend","Hello, %1$s")=>"friend"LibDeformat("Cost: $100","Cost: $%d")=>100-- note that it converted it back to a numberLibDeformat("Cost: $100","Cost: $%1$d")=>100LibDeformat("Alpha, Bravo","%s, %s")=>"Alpha","Bravo"LibDeformat("Alpha, Bravo","%1$s, %2$s")=>"Alpha","Bravo"LibDeformat("Alpha, Bravo","%2$s, %1$s")=>"Bravo","Alpha"-- this can happen in foreign languagesLibDeformat("Hello, friend","Cost: $%d")=>nil-- nil is returned when there is no match

When I adapted LibItemBonus to LibStub, I had to drop Deformat and use my own solution. After some refinement, I finally got a working solution (GetPattern) which does pretty much what LibDeformat-3.0 does, except without caching. (The API returns a callable that can be reused to check new strings). i.e: