Hi guys i am trying to regex this string whereby i could change the digit at the "0" part. The requirement is that i only want the number 1. findstr to change digit when regex is carried out and not number 2 as they are in the same text file....thanks in advance!! 1.findstr /i /C:"LSAAnonymousNameLookup = 0" C:\major_security_settings1.txt 2.findstr /C:"LSAAnonymousNameLookup = 0" C:\major_security_settings1.txt
Even if your question looks that you didnt try it yourself i will spoonfeed you just to increase my postcount. $result = preg_replace('%(findstr /i /C:"LSAAnonymousNameLookup = )\d+(" C:\\\\major_security_settings1.txt)%im', '\1$yourNumberHere\2', $subject); Code (markup): $subject=<<<SSS 1.findstr /i /C:"LSAAnonymousNameLookup = 0" C:\major_security_settings1.txt 2.findstr /C:"LSAAnonymousNameLookup = 0" C:\major_security_settings1.txt SSS; $result = preg_replace('%(findstr /i /C:"LSAAnonymousNameLookup = )\d+(" C:\\\\major_security_settings1.txt)%im', '\1$yourNumberHere\2', $subject); echo $result; Code (markup): Have fun and maybe get some education some day!
thanks anyway, actually i have tried for quite long! The problem is that it wont let me replace the digit with the value "0", i tried changing the value of "disabled" to like 2 for example and it works..[0-9] should be able to accept the digit 0 right? $batch_contents = preg_replace('~(findstr /i /C:"LSAAnonymousNameLookup = )([0-9])~', '${1}'.$newArgument3, $batch_contents); <p> <form action="editsecurity.php" method='post'> Network Access:Allow Anonymous SID/Name Translation:<select name="SID"> <option selected=""></option> <option value="1">Enable</option> <option value="0">Disable</option> </select><p>
I think its ok to post your previous attempts with your question. So it wont look like you just need your homework done from someone here Yes, [0-9] matches a digit from 0 to 9 and \d will do the same. I do not get the actual problem. It's solved? have you checked my examples i did for you?
alright it works now that i omit out !empty($_POST['SID']) in my if statement..thanks for the help dude