Jump to content

string formatting...


Recommended Posts

Help? I need to convert a string like this:

ce00062e7e206641bdb3388a05ccbd52

to a string like this:

ce,00,06,2e,7e,20,66,41,bd,b3,38,8a,05,cc,bd,52

I'm sure there is an easy way to do it, I'm just too stupid to figure it out.

Thanks!

This signature is computer generated, nothing can go wron#nothing can go wron#nothing can go wron#nothing can go wron#nothing can go wron#nothing can go wron#nothing can go wron#nothing can go wron#nothing can go wron#nothing can go wron#nothing can go wron#.......

Link to comment
Share on other sites

Yea there is a pretty easy way of doing it...

$cString = "ce00062e7e206641bdb3388a05ccbd52"
$aString = StringSplit($cString, "")

For $i = 1 to $aString[0] Step 2
   $sString = $sString & $aString[$i] & $aString[$i +1] & ","
Next

MsgBox(0, "Test Output", $sString)

Please keep in mind this method is untested.

JS

AutoIt Links

File-String Hash Plugin Updated! 04-02-2008 Plugins have been discontinued. I just found out.

ComputerGetInfo UDF's Updated! 11-23-2006

External Links

Vortex Revolutions Engineer / Inventor (Web, Desktop, and Mobile Applications, Hardware Gizmos, Consulting, and more)

Link to comment
Share on other sites

Help? I need to convert a string like this:

ce00062e7e206641bdb3388a05ccbd52

to a string like this:

ce,00,06,2e,7e,20,66,41,bd,b3,38,8a,05,cc,bd,52

I'm sure there is an easy way to do it, I'm just too stupid to figure it out.

Thanks!

<{POST_SNAPBACK}>

You could try this:

$str = "ce00062e7e206641bdb3388a05ccbd52"
$sNew = ''

For $i=1 to StringLen($str) Step 2
    $sNew = $sNew & StringMid($str, $i, 2) & ','
Next
$sNew = StringTrimRight($sNew, 1)

MsgBox(0, "Result", $sNew)
Link to comment
Share on other sites

You could try this:

$str = "ce00062e7e206641bdb3388a05ccbd52"
$sNew = ''

For $i=1 to StringLen($str) Step 2
    $sNew = $sNew & StringMid($str, $i, 2) & ','
Next
$sNew = StringTrimRight($sNew, 1)

MsgBox(0, "Result", $sNew)

<{POST_SNAPBACK}>

Thanks guys! I ended up using a slight different method but I'm sure either of yours would work. I might use one to cleanup my bloated code :)

This signature is computer generated, nothing can go wron#nothing can go wron#nothing can go wron#nothing can go wron#nothing can go wron#nothing can go wron#nothing can go wron#nothing can go wron#nothing can go wron#nothing can go wron#nothing can go wron#.......

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...