LoginSignup
0
0

More than 3 years have passed since last update.

C++で正規表現が使いたい

Last updated at Posted at 2019-09-09

最初に

pythonでは正規表現re.subなんかを使うと簡単にテキストの中身が変えられちゃう!!  

regex

元も子もないがこっちを読んだ方が良い
標準C++ライブラリwikipedia

C++でしたい

      // "," の置換 
      string str5 = "0000,0001,0002";     // 置き換えたい文字列
      string okikawaru = ",";      // 文字列
      string okikaeru = " "; // 置換文字列
      if (!okikawaru.empty())
      {
         string::size_type post = 0;
         while ((post = str5.find(okikawaru, post)) != string::npos)
         {
            str5.replace(post, okikawaru.length(), ikikaeru);
            post += ikikaeru.length();
         }
      }

結果


0000 0001 0002

となる

0
0
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0