memerim Posted August 15, 2019 Share Posted August 15, 2019 I have a proxy file with many ips, and i need find all line with <Username>iucbzmbl-xx</Username> and replace "xx" to 100, next 101, next 102 This: <Proxy id="170" type="HTTPS"> <Address>142.44.223.144</Address> <Port>80</Port> <Options>48</Options> <Authentication enabled="true"> <Username>iucbzmbl-51</Username> <Password></Password> </Authentication> </Proxy> <Proxy id="171" type="HTTPS"> <Address>142.44.223.144</Address> <Port>80</Port> <Options>48</Options> <Authentication enabled="true"> <Username>iucbzmbl-59</Username> <Password></Password> </Authentication> </Proxy> <Proxy id="172" type="HTTPS"> <Address>142.44.223.144</Address> <Port>80</Port> <Options>48</Options> <Authentication enabled="true"> <Username>iucbzmbl-62</Username> <Password></Password> </Authentication> </Proxy> To this: <Proxy id="170" type="HTTPS"> <Address>142.44.223.144</Address> <Port>80</Port> <Options>48</Options> <Authentication enabled="true"> <Username>iucbzmbl-100</Username> <Password></Password> </Authentication> </Proxy> <Proxy id="171" type="HTTPS"> <Address>142.44.223.144</Address> <Port>80</Port> <Options>48</Options> <Authentication enabled="true"> <Username>iucbzmbl-101</Username> <Password></Password> </Authentication> </Proxy> <Proxy id="172" type="HTTPS"> <Address>142.44.223.144</Address> <Port>80</Port> <Options>48</Options> <Authentication enabled="true"> <Username>iucbzmbl-102</Username> <Password></Password> </Authentication> </Proxy> I searched about, found this function: https://www.autoitscript.com/autoit3/docs/functions/StringReplace.htm How can i search the bold part <Username>iucbzmbl-xx</Username> and replace it in the function adding +1 to each value found. 😦 $String = 'C:\Users\CAIO\Downloads\proxy2.ppx' StringReplace ( $string, "iucbzmbl", "replacestring" ) Link to comment Share on other sites More sharing options...
Malkey Posted August 15, 2019 Share Posted August 15, 2019 Try this example. expandcollapse popup#cs <Proxy id="170" type="HTTPS"> <Address>142.44.223.144</Address> <Port>80</Port> <Options>48</Options> <Authentication enabled="true"> <Username>iucbzmbl-51</Username> <Password></Password> </Authentication> </Proxy> <Proxy id="171" type="HTTPS"> <Address>142.44.223.144</Address> <Port>80</Port> <Options>48</Options> <Authentication enabled="true"> <Username>iucbzmbl-59</Username> <Password></Password> </Authentication> </Proxy> <Proxy id="172" type="HTTPS"> <Address>142.44.223.144</Address> <Port>80</Port> <Options>48</Options> <Authentication enabled="true"> <Username>iucbzmbl-62</Username> <Password></Password> </Authentication> </Proxy> #ce Local $String = StringRegExpReplace(FileRead(@ScriptFullPath), "(?is)^.*?#cs\s+|\s+#ce.*$", "") ; Get test $String from comment block in this script. ; or ;Local $String = FileRead('C:\Users\CAIO\Downloads\proxy2.ppx') Local $sStart = "<Username>iucbzmbl-" Local $sEnd = "</Username>" Local $iInit = 100 - 1 ConsoleWrite(Execute("'" & StringRegExpReplace($String, "(?i)(?<=" & $sStart & ")(\d+)(?=" & $sEnd & ".*?)", "'&$iInit+Assign('iInit',$iInit+1)&'") & "'") & @CRLF) memerim 1 Link to comment Share on other sites More sharing options...
memerim Posted August 16, 2019 Author Share Posted August 16, 2019 @Malkey thank you! work like a charm Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now