I use it for quick and dirty animation loading. Really convenient when it comes to generating a list of path strings. Hopefully it could save you some time. Github: interpStr
It’s capable of generating the following string variations.
Example
Input: /this/is/a/string[01-03].png
Return:
/this/is/a/string01.png
/this/is/a/string02.png
/this/is/a/string03.png
Rules like [1-3], [01-10], [01,02,03-10,11,12] will all give expected output.
Nice idea, I’ve been writing config files recently for my pet project and currently list each asset variation separately. I don’t have more than 5 in any case but this is a much cleaner approach. The only downside I can think of is when you want to associate more information with an asset, like an animation or a colour tint for example. But for the case where you just want to list some variations shorthand this is perfect
And of course your restricted to naming your variations with numbers instead of something more descriptive like: red car, blue car, green car, etc. But this is a minor issue.
I tried to make a change and submit a pull request but am getting permission errors, so I’ve given up (life’s too short to spend hours struggling with supposedly easy-to-use GitHub!!)
Here’s teh code I changed
std::vector<std::string> expand;
for(const Range& r : rangeList) {
int diff = 1;
if (r.begin>r.end)
diff = -1;
int i = r.begin;
do{
std::stringstream ss;
ss << std::setw(r.padding+1) << std::setfill('0') << std::to_string(i);
std::string out = std::regex_replace(path, re, ss.str());
expand.push_back(out);
i += diff;
} while (i != r.end);
}
Which adds the ability to use ranges like [9-1] so it is in reverse order - which is something I needed.