usala cosi'codice:string find_pat(string where, int * pos, string start, string end) { int pos2, pos3; int work=1; pos2=*pos; while(work) { pos2 = where.find (end, pos2); if(pos2 == string::npos) return string(""); pos3 = where.rfind (start, pos2); if(pos3 == string::npos || pos3 < *pos) { pos2 = pos2 + end.length() ; } else { pos3 += start.length(); work=0; } } *pos=pos2+end.length(); return where.substr (pos3, pos2-pos3); }
codice:int pos = 0; string s = find_pat("Salve, io sono una stringa", &pos, string("Salve,"), "sono una stringa"); cout << s;

Rispondi quotando