- 637 名前:デフォルトの名無しさん mailto:sage [2006/11/10(金) 12:45:17 ]
- int main()
{ char line[255]; int count = 1; ifstream ifs; string str; ifs.open("test.txt", ios::in); // 読み取り専用で開く BREGEXP *rxp = NULL;// 必ずクリアしておくこと char msg[80]; std::string aa = "あい"; std::string bb = "うえ"; char patern1[100]= "s/"aa"/"bb"/g"; int ctr; while( !ifs.eof() ){ ifs.getline(line, sizeof(line)); std::string str1 = line; // 空のstring ctr = BSubst("s/"aa"/"bb"/g",line,line+strlen(line),&rxp,msg); printf("after(%d)=%s\n",ctr,rxp->outp);// 置換したパターン数と文字列 printf("length=%d\n",rxp->outendp - rxp->outp);// 置換後の文字数 count++; } ifs.close(); ifs.close(); if (rxp)// コンパイルブロックの開放 BRegfree(rxp);// 忘れないように return 0; } 試行錯誤しております。検索・置換に変数と正規表現を使用したいのですが、うまくいきません。
|

|