I want to replace ID from file containing many more ID and make it random. I really struggle to get it through. Any idea?
ID_List.txt:
Begin
Name: Person
Phone;type=Main:+1 234 567 890
ID;Type=Main:132dfi987416
End
Begin
Name: OtherPerson
Phone;type=Main:5598755131
ID;Type=Main:549875413213
ID;Type=Seco:987987565oo2
End
Begin
Name: TheOtherPerson
Phone;type=Main:+58 321 654 987
ID;Type=Main:6565488oop24
ID;Type=Seco:7jfgi0897540
ID;Type=Depr:6544654650ab
End
I have to use C++ and thought that regex could be my way out. Thus my
regex:
(?<=ID;Type=....:).*$
C++:
#include <iostream>
#include <math>
#include <string>
#include <cstdlib>
#include <ctime>
#include <fstream>
#include <regex>
#include <iterator>
using namespace std;
string in_file;
srand (time(NULL));
void write();
int randomizer();
int main() {
int a,b,c,x,y,z,n;
cout << "Input File: "; getline(cin, in_file);
return 0;
}
void write() {
fstream source;
source.open(in_file.c_str());
? CODE HERE ?
}
int randomizer (){
int x;
X = rand() % 10 + 0;
return x;
}