Hodahel Posted October 4, 2013 Share Posted October 4, 2013 Hey guys, Can somebody help me with this? Used word: AA:BB:CC Constant word: 12345_5678 I need a script to take the last 3 character from AA:BB:CC, EXCEPT for the ":" symbol so that the result will be: 12345BCC_5678 TIA Link to comment Share on other sites More sharing options...
mrflibblehat Posted October 4, 2013 Share Posted October 4, 2013 (edited) How I would do it, most likely not the easiest way as I'm Sure it could be done with StringRegExpReplace $vWord = "AA:BB:CC" $vConstantWord = "12345_5678" $vString = StringRight(StringReplace($vWord,":", ""), 3) ;~ AABBCC $vString2 = StringSplit($vConstantWord, "_", 2) ;~ Split Constant Word Into Array $vOutput = ($vString2[0] & $vString & "_" & $vString2[1]) ;~ 12345, BCC, _, 5678 ConsoleWrite($vOutput) Edited October 4, 2013 by mrflibblehat Hodahel 1 [font="'courier new', courier, monospace;"]Pastebin UDF | Prowl UDF[/font] Link to comment Share on other sites More sharing options...
Solution Malkey Posted October 4, 2013 Solution Share Posted October 4, 2013 A StringRegExpReplace method. Local $vWord = "AA:BB:CC" Local $vConstantWord = "12345_5678" Local $vOutput = StringRegExpReplace($vConstantWord, "(^[^_]+)(.+)$", "${1}" & StringRegExpReplace($vWord, "^.+(\w):(\w{2})$", "\1\2") & "${2}") ConsoleWrite($vOutput & @LF) Hodahel and mrflibblehat 2 Link to comment Share on other sites More sharing options...
Hodahel Posted October 5, 2013 Author Share Posted October 5, 2013 Thank you guys! This code works too.. local $mystring = "AA:BB:CC" $theStr = StringSplit($mystring, ":") ; Create an array $theNewStr = "" For $i = 1 to $theStr[0] Step 1 $theNewStr = $theNewStr & $theStr[$i] Next Local $result = StringTrimLeft($theNewStr, 3) MsgBox(0, "New Text:", "12345" & $result & "_5678") 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