博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
C++ 常用的字符串处理函数实现
阅读量:7117 次
发布时间:2019-06-28

本文共 931 字,大约阅读时间需要 3 分钟。

以下是一些标准库没有实现的函数,我觉得很方便就写了,估计会不定时更新。

1  //根据一个文件的路径获取文件名 2    3  std::string file_name(const std::string& path) 4  { 5       return path.substr(path.find_last_of("/\\") + 1); 6   } 7    8     9   10  //根据一个文件的路径获取该文件的路径11  12  std::string base_name(const std::string& path)13  14  {15 16  }17 18 19 20  //根据一个文件的路径获取该文件的扩展名21  22  std::string file_extension(const std::string& path)23 24  {25 26   std::string::size_type idx;27 28  idx = filename.rfind('.');29 30  return (idx != std::string::npos) ? filename.substr(idx+1) : "";31 32  }33 34 //C++ 字符串分隔35 std::vector
split(const std::string& input, const std::string& regex) {36 // passing -1 as the submatch index parameter performs splitting37 std::regex re(regex);38 std::sregex_token_iterator39 first{ input.begin(), input.end(), re, -1 },40 last;41 return{ first, last };42 }

 

转载于:https://www.cnblogs.com/foohack/p/5553674.html

你可能感兴趣的文章
Java多线程:死锁
查看>>
【深度学习系列】CNN模型的可视化
查看>>
memory consistency
查看>>
CSS选择器的新用法
查看>>
PowerShell 并行执行任务
查看>>
C++中的const成员函数(函数声明后加const,或称常量成员函数)用法详解
查看>>
VC++ Splash Window封装类CSplash
查看>>
wcf配置参数说明
查看>>
假期小结 BIO, NIO, AIO
查看>>
小知识温习重点摘要
查看>>
Comparable和Comparator的区别
查看>>
WEB服务器搭建–IIS
查看>>
Chromium Settings页面修改
查看>>
如何用Python计算Softmax?
查看>>
给你的app添加桌面widget
查看>>
h5移动端混编总结
查看>>
Jvm(57),类加载器----初次认识加载器
查看>>
IntelliJ Idea 常用快捷键列表
查看>>
开始使用Chronograf(官方说明)
查看>>
loading
查看>>