Hello guys i want to replace the value at the "0x1" part from this three findstr function in a file. I have tried doing it for an hour but i still can't do it so i need a lil help...thanks findstr /i /C:"0x1" C:\reg1.txt findstr /i /C:"0x1" C:\reg2.txt findstr /i /C:"0x1" C:\reg3.txt This is what i tried below $batch_contents = preg_replace('~"([a-z0-9_ -]+)"\sC:\reg1.txt ~i', '$newArgument.\sC:\reg1.txt', $batch_contents); $batch_contents = preg_replace('~"([a-z0-9_ -]+)"\sC:\reg2.txt ~i', '$newArgument.\sC:\reg2.txt', $batch_contents);
If its a constant 0x1 then str_replace might be easier. Can you post what you have exactly and your desired result, your above post is a little confusing.
Basically i'm doing an edit function i want this line -> findstr /i /C:"0x1" C:\reg1.txt to be changed to - > findstr /i /C:"0x2" C:\reg1.txt for example..
If it's not a constant, something like this would suffice: <?php $string = 'findstr /i /C:"0x1" C:\reg1.txt'; $replacement_text = 'replaced'; $string = preg_replace('#(?<=findstr\s/i\s/C:")(.*?)(?="\sC:\\\\reg1.txt)#i', $replacement_text, $string); echo $string; ?> PHP: