caramen Posted August 16, 2018 Share Posted August 16, 2018 I am calculate a variable with string commands I got a random return like : 1:Marie Dupont 2:Jean-Ethienne Durand 3:Elise Lucet 4:Mickael-Jacksone How to transforme into 1:MarieDupont 2:Jean-EthienneDurand 3:EliseLucet 4:Mickael-Jacksone I tryed a lot of StringBetween I tryed StringMid Cant get this working My video tutorials : ( In construction ) || My Discord : https://discord.gg/S9AnwHw How to Ask Help || UIAutomation From Junkew || WebDriver From Danp2 || And Water's UDFs in the Quote Spoiler Water's UDFs:Active Directory (NEW 2018-10-19 - Version 1.4.10.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX (2018-10-31 - Version 1.3.4.1) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsPowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & SupportExcel - Example Scripts - WikiWord - Wiki Tutorials:ADO - Wiki Link to comment Share on other sites More sharing options...
BrewManNH Posted August 16, 2018 Share Posted August 16, 2018 StringStripWS caramen 1 If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator Link to comment Share on other sites More sharing options...
Malkey Posted August 17, 2018 Share Posted August 17, 2018 See StringRegExpReplace() or StringReplace(). Local $sString = _ "1:Marie Dupont" & @CRLF & _ "2:Jean-Ethienne Durand" & @CRLF & _ "3:Elise Lucet" & @CRLF & _ "4:Mickael-Jacksone" ConsoleWrite("--- StringStripWS ---" & @CRLF) ConsoleWrite(StringStripWS($sString, 8) & @CRLF & "---- StringRegExpReplace ---" & @CRLF) ConsoleWrite(StringRegExpReplace($sString, "\h+", "") & @CRLF & "--- StringReplace ---" & @CRLF) ConsoleWrite(StringReplace($sString, " ", "") & @CRLF) #cs ; Returns:- --- StringStripWS --- 1:MarieDupont2:Jean-EthienneDurand3:EliseLucet4:Mickael-Jacksone ---- StringRegExpReplace --- 1:MarieDupont 2:Jean-EthienneDurand 3:EliseLucet 4:Mickael-Jacksone --- StringReplace --- 1:MarieDupont 2:Jean-EthienneDurand 3:EliseLucet 4:Mickael-Jacksone #ce Link to comment Share on other sites More sharing options...
iamtheky Posted August 17, 2018 Share Posted August 17, 2018 Also, there is fun to be had with @Tekk's ASM character replace. Though using a separator incorrectly is probably not the best choice, but its more for sport anyway. Local $s = _ "1:Marie Dupont" & @CRLF & _ "2:Jean-Ethienne Durand" & @CRLF & _ "3:Elise Lucet" & @CRLF & _ "4:Mickael-Jacksone" msgbox(0, '' , StringReplaceAll($s , " " , ChrW("30"))) Func StringreplaceAll($sString, $sProbe, $sPatch) Local $tProc = DllStructCreate("BYTE ASM[20]") ;~ AutoIt allocates memory with execute rights? ;~ I have NX bit enabled, I assumed issues if not explicitly giving execute rights $tProc.ASM = "0x" _ & "8B742404" _ ;~ mov esi, dword[esp+4] -> get start address (pointer) of the string & "AC" _ ;~ @@: lodsb -> load char from [esi] to al & increment esi by one & "3C00" _ ;~ cmp al, 0 -> is char = 0 & "740A" _ ;~ jz @f -> if yes then jump to return & "3C" & Hex(Asc($sProbe), 2) _ ;~ cmp al, NNh -> if not then compare with $sProbe & "75F7" _ ;~ jne @b -> if not equal then load next byte from string & "C646FF" & Hex(Asc($sPatch), 2) _ ;~ mov byte[esi-1], NNh -> if equal then replace with $sPatch & "EBF1" _ ;~ jmp @b -> load next byte from string & "C3" ;~ @@: ret -> return ;~ Technically shouldn't we preserve esi? Return DllCallAddress("NONE:cdecl", DllStructGetPtr($tProc), "STR", $sString)[1] EndFunc ,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-. |(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/ (_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_) | | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) ( | | | | |)| | \ / | | | | | |)| | `--. | |) \ | | `-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_| '-' '-' (__) (__) (_) (__) 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