編輯 C++ 正則表達式須要不斷嘗式,網路上找到一個簡單的程式碼(一時找不到在哪看到)蠻不錯的,留一份在這
#include <iostream>
#include <regex>
using namespace std;
int main()
{
  // regex reg("[\\.]|[\\b]+$");
  //regex reg("([.]*)([\\.]+)([.]*)");
  //regex reg(".*(\\.+).*");
  //regex reg(".*(\\s$)");
  //regex reg(".*(\\.+).*|.*(\\s$)");
  //regex reg("[\\s]+");
  regex reg("Applications\\\\.+_\\.bbbbb");
  string input;
  smatch sm;
  while(true)
  {
    cout << "Enter: ";
    getline(cin, input);
    if(input == "quit")
      break;
    if( regex_match(input, sm , reg) )
    {
      cout << "Match!" << endl;
      for( unsigned int i = 0 ; i < sm.size() ; ++i )
      {
        cout << i << ": [" << sm[i] << ']' << endl;
      }
    }
    else
    {
      cout << "Not Match!" << endl;
    }
  }
    return 0;
}
