add star_subst() utility function that replaces a '*' in a string with a number
This commit is contained in:
@ -791,11 +791,23 @@ std::string utils::trim(const std::string &line)
|
||||
|
||||
std::string utils::trim_comment(const std::string &line)
|
||||
{
|
||||
auto end = line.find_first_of('#');
|
||||
auto end = line.find('#');
|
||||
if (end != std::string::npos) { return line.substr(0, end); }
|
||||
return {line};
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
Replace '*' with number and optional zero-padding
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
std::string utils::star_subst(const std::string &name, bigint step, int pad)
|
||||
{
|
||||
auto star = name.find('*');
|
||||
if (star == std::string::npos) return name;
|
||||
|
||||
return fmt::format("{}{:0{}}{}",name.substr(0,star),step,pad,name.substr(star+1));
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
Replace UTF-8 encoded chars with known ASCII equivalents
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
Reference in New Issue
Block a user