Search the Community
Showing results for tags 'asterisk'.
-
Hallo forum members, I am looking for a pattern to replace user= and password= between double quotes user="Alfa75" becomes user="*****" password="xstsgSvs" becomes password="*****" In my example the opposite happens, username and password is still visable StringReplace or StringRegExpReplace is not my best skill Opt("MustDeclareVars", 1) Global $Config = @ScriptDir & "\config.xml" _Config() Func _Config() If FileExists($Config) Then Local $file = FileOpen($Config, 0) Local $sData = FileRead($file) FileClose($file) Local $rData = StringRegExpReplace($sData, "(user=Chr(34)).+?(password=Chr(34)", "\1") ;$rData = StringReplace($rData, "user=", "*****") ; <-- desired with asterisk ;$rData = StringReplace($rData, "password=", "*****") ; <-- desired with asterisk $rData = StringReplace($rData, "user=", "") $rData = StringReplace($rData, "password=", "") MsgBox(0, "config.xml : ", $rData) ;ClipPut($rData) Else MsgBox(0, "config.xml : ", "Not found") EndIf EndFunc config.xml <config> <line short="LT" city="ASD" user="Alfa75" password="xstsgSvs" code="020" registered="1" period="20" /> <line short="IC" city="RTD" user="Jonh09" password="Gdte55567" code="010" registered="1" period="25" /> <line short="IB" city="UT" user="2ronals" password="B776656" code="030" registered="0" period="15" /> <line short="IC" city="RTD" user="DEjong67" password="=0gdd++00L==" code="010" registered="1" period="25" /> <line short="ST" city="AML" user="Eddy03" password=".te555=77Ai" code="036" registered="1" period="25" /> <line short="LT" city="CAS" user="BassB" password="+gdtWU=" code="0251" registered="1" period="35" /> <line short="IC" city="DT" user="lian033" password="77t--e55+=" code="015" registered="1" period="45" /> </config> desired result <config> <line short="LT" city="ASD" user="*****" password="*****" code="020" registered="1" period="20" /> <line short="IC" city="RTD" user="*****" password="*****" code="010" registered="1" period="25" /> <line short="IB" city="UT" user="*****" password="*****" code="030" registered="0" period="15" /> <line short="IC" city="RTD" user="*****" password="*****" code="010" registered="1" period="25" /> <line short="ST" city="AML" user="*****" password="*****" code="036" registered="1" period="25" /> <line short="LT" city="CAS" user="*****" password="*****" code="0251" registered="1" period="35" /> <line short="IC" city="DT" user="*****" password="*****" code="015" registered="1" period="45" /> </config>
- 8 replies
-
- double quotes
- asterisk
-
(and 1 more)
Tagged with: