Mannyfresh15 Posted July 1, 2016 Share Posted July 1, 2016 (edited) I need some help inserting two zeros every other two characters in a string #include <String.au3> $sString = "manny1" $NewString = _StringInsert ( $sString, "00",0 ) MsgBox (0,"Hello" , "Your String After Inserting 00's " & $NewString ,0) the outcome need to be ma00nn00y100 but IDK how to do it. Please help. Edited July 1, 2016 by Mannyfresh15 Link to comment Share on other sites More sharing options...
Jfish Posted July 1, 2016 Share Posted July 1, 2016 (edited) #include <String.au3> $sString = "manny1" for $a=StringLen($sString) to 1 step -2 $sString=_StringInsert ($sString, "00",$a) Next MsgBox (0,"Hello" , "Your String After Inserting 00's " & $sString ,0) Edited July 1, 2016 by Jfish Mannyfresh15 1 Build your own poker game with AutoIt: pokerlogic.au3 | Learn To Program Using FREE Tools with AutoIt Link to comment Share on other sites More sharing options...
Mannyfresh15 Posted July 1, 2016 Author Share Posted July 1, 2016 1 minute ago, Jfish said: #include <String.au3> $sString = "manny1" for $a=StringLen($sString) to 1 step -2 $sString=_StringInsert ($sString, "00",$a) MsgBox(0,'',$sString) Next MsgBox (0,"Hello" , "Your String After Inserting 00's " & $sString ,0) Thank you very much that works just fine... (: Link to comment Share on other sites More sharing options...
Jfish Posted July 1, 2016 Share Posted July 1, 2016 Glad I could help ... you may want to remove the extra message box from the for loop like I did in my edited post ... Mannyfresh15 1 Build your own poker game with AutoIt: pokerlogic.au3 | Learn To Program Using FREE Tools with AutoIt Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted July 1, 2016 Moderators Share Posted July 1, 2016 Mannyfresh15, Or you could do something like this: $sString = "manny1" $aRet = StringRegExp($sString, "(.{2})", 3) $sNewString = "" For $i = 0 To UBound($aRet) - 1 $sNewString &= $aRet[$i] & "00" Next MsgBox(0, "Result", $sNewString) M23 Mannyfresh15 and Jfish 2 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
ViciousXUSMC Posted July 1, 2016 Share Posted July 1, 2016 (edited) Meh I'll throw my 2 cents into the pot. $sString = "manny1" $sNewString = StringRegExpReplace($sString, "(.{2})", "${0}00") MsgBox(0, "Result", $sNewString) One Liner just for fun: MsgBox(0, "Results", StringRegExpReplace("Manny1", "(..)", "${0}00")) Edited July 1, 2016 by ViciousXUSMC Mannyfresh15 1 Link to comment Share on other sites More sharing options...
Mannyfresh15 Posted July 1, 2016 Author Share Posted July 1, 2016 You guys are Awesome! All your codes work like a charm! Link to comment Share on other sites More sharing options...
mikell Posted July 1, 2016 Share Posted July 1, 2016 My 2 cents $sString = "manny1" $sNewString = StringRegExpReplace($sString, '..\K', "00") MsgBox(0, "Result", $sNewString) Mannyfresh15 and Melba23 2 Link to comment Share on other sites More sharing options...
Mannyfresh15 Posted July 1, 2016 Author Share Posted July 1, 2016 @mikell thanks for those cents Link to comment Share on other sites More sharing options...
SadBunny Posted July 3, 2016 Share Posted July 3, 2016 I am so curious... What's the use? This sounds like the kind of thing that solves a problem that need not be there in the first place, i.e. it may be useful to explain the bigger picture, maybe you'll get some better ideas? Roses are FF0000, violets are 0000FF... All my base are belong to you. 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