#include <regex>
std::regex numberPrefixRegex(R"(^\d)"); // Regex to match strings starting with a number
std::string str;
// define folderName
if (std::regex_search(str, numberPrefixRegex))
{
std::cout << str << std::endl;
}
#include <filesystem>
for (const auto& entry : std::filesystem::directory_iterator(sourceDir))
{
const std::filesystem::path& sourcePath = entry.path();
std::filesystem::path destinationPath = std::filesystem::path(destinationDir) / sourcePath.filename();
// Move file or directory
std::filesystem::rename(sourcePath, destinationPath);
std::cout << "Moved: " << sourcePath << " -> " << destinationPath << std::endl;
}
fmt
is an open-source formatting library for C++ that provides a fast and type-safe alternative to the standard library’s printf and std::stringstream formatting functions. It allows developers to construct strings with embedded variable values using a modern and readable syntax.
#include <fmt/core.h>
int main() {
int num = 42;
std::string name = "Alice";
// Format string with placeholders
std::string result = fmt::format("Hello, {}! Your number is {}.", name, num);
// Print to console
fmt::print("{}\n", result);
return 0;
}