rootx Posted September 6, 2017 Share Posted September 6, 2017 (edited) Hi, I need I trick to remove all double or triple etc... backslash. Thx $string = "I:\test\\xxx\jjj\\\kkk\k.jpg" Mmmm, I found a way but if you have more elegant way, please post it! $string = "I:\test\\xxx\jjj\\\kkk\k.jpg" $root = StringTrimRight($string,StringLen($string)-3) $aArray = _StringBetween($string, "\", "\") For $i = UBound($aArray) - 1 To 0 Step -1 If $aArray[$i] = "" Then _ArrayDelete($aArray, $i) EndIf Next $string2 = _ArrayToString($aArray,"\") MsgBox("","",$root&$string2) Edited September 6, 2017 by rootx Link to comment Share on other sites More sharing options...
Simpel Posted September 6, 2017 Share Posted September 6, 2017 (edited) Hi. I'm not sure if you really mean remove or mean replace woth only one "\". I guess second. So here is my try with StringRegExpReplace(): Local $string = "I:\test\\xxx\jjj\\\kkk\k.jpg" $string = StringRegExpReplace($string, "\\+", "\\") ConsoleWrite($string & @CRLF) Explanation: searchstring - \\+ - first \ is only masking second\ (otherwise it has another function) and + means one till all \ Replace it with \\. Here the first \ is masking the second \ again. Conrad Edited September 6, 2017 by Simpel add explanation krasnoshtan and rootx 1 1 SciTE4AutoIt = 3.7.3.0 AutoIt = 3.3.14.2 AutoItX64 = 0 OS = Win_10 Build = 19044 OSArch = X64 Language = 0407/german H:\...\AutoIt3\SciTE H:\...\AutoIt3 H:\...\AutoIt3\Include (H:\ = Network Drive) Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind. Link to comment Share on other sites More sharing options...
Danyfirex Posted September 6, 2017 Share Posted September 6, 2017 This should work. $string = "I:\test\\xxx\jjj\\\kkk\k.jpg" $string=StringRegExpReplace($string,"\\{2,}","\\") ConsoleWrite($string & @CRLF) Saludos rootx and krasnoshtan 2 Danysys.com AutoIt... UDFs: VirusTotal API 2.0 UDF - libZPlay UDF - Apps: Guitar Tab Tester - VirusTotal Hash Checker Examples: Text-to-Speech ISpVoice Interface - Get installed applications - Enable/Disable Network connection PrintHookProc - WINTRUST - Mute Microphone Level - Get Connected NetWorks - Create NetWork Connection ShortCut Link to comment Share on other sites More sharing options...
Simpel Posted September 6, 2017 Share Posted September 6, 2017 Difference between @Danyfirex and mine: My script replaces all existing \, \\, \\\ ... with \ and Danyfirex' starts with minimum 2 \\ - so \\,\\\ ... Conrad SciTE4AutoIt = 3.7.3.0 AutoIt = 3.3.14.2 AutoItX64 = 0 OS = Win_10 Build = 19044 OSArch = X64 Language = 0407/german H:\...\AutoIt3\SciTE H:\...\AutoIt3 H:\...\AutoIt3\Include (H:\ = Network Drive) Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind. Link to comment Share on other sites More sharing options...
rootx Posted September 6, 2017 Author Share Posted September 6, 2017 THX Guys! 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