Loop trough files and replace variable values between quotes
-
Not yet. Still looking for a way to extract and replace the values that are inside quotes after the first known part of the string.
If i had such function, it would be easy to exchange all variables from the partially known lineHence my question :)
-
Hi and welcome to devnet,
You provided only input examples. Can you also provide a complete before/after example ?
-
Hi!
The output variables are generated by an external algortithm much like Bitcoin.
So new hash values and variables need to get 'computed' first and are all related to each other.So the output is truly random, the only part that i know for sure are the leading string that identify them in the sources.
So to shorten my request, what i need is a nice, optimized function to :
- Open the file
- Match a whole line by the leading string
- Split is somewhere after the leading string and replace the variables OR replace with a regex between the quotes
- Write back to file
My current code opens every file multiple times for each new string i need to replace.
So optimized, it would open 1 file and look for ALL the predefined strings i need to replace.Hope this helps :)
Thank you
-
Do you know all the strings you have to search before opening the file ?
-
Then I'd build something like a vector containing the string/regexp to search along with their replacement and loop on that over a buffer containing your file data. Then you wouldn't need to open every file several times.
-
Thank you.
Right now i'm looking to replace the fixed lines using their known line numbers, split the strings, extract the values and join them back.
This seems to work. However, i have several multiline codeblocks that needs replacement between {}, and now i'm stucked with those. :)
-
Hi
several multiline codeblocks ?
That is a new type it seems? -
As example:
int64_t DoSomeFunctionHere(int64_t param1, int64_t param2) { Some line of code here Some line of code here return Param1 + Param2; }
So i need to look for DoSomeFunctionHere and replace everything that follows inside the { and }
-
Ok, so that is still "0x0" type
for "Some line of code here"
or new case? -
@WD30EFRX
Ok that could be an option too,
If u use something like
https://www.freelancer.comMake sure to describe the problem very carefully with
actual samples of what to find and what to replace with and the
different cases. Also what " first known part of the string." is. and so on.
Also, if the files are in subfolder etc.Else you wont get a good estimate of the cost.