Jump to content

Recommended Posts

Posted

Hi to all.

I need somebody`s tip about manipulating with strings:

Say i have hex string like this:

%u56e8%u0000%u5300%u5655%u8b57%u246c%u8b18%u

And as result i write small scenario for replace "%u"(without quotes) with ":"(without quotes)

Below scenario:

$a ="%u56e8%u0000%u5300%u5655%u8b57%u246c%u8b18%u"             ; this is my hex string
$s = StringReplace($a, "%u", ":")
MsgBox(64, "string is", $s)

In MessageBoxA it returns me:

:56e8:0000:5300:5655:8b57:246c:8b18:

This is right of course:

But in 2`nd stage i have question which i need really somebody`s tips.

How to do that in $s for get string like below.

(Note: As result my target is modify $s and get string like below)

:56:e8:00:00:53:00:56:55:8b:57:24:6c:8b:18:

Have somebody any tips ?

I can realise it in Perl without any problems(for ex)

#!/usr/bin/perl
no warnings;
my $b =":56e8:0000";
chomp($b);
my $a = substr $b, 0, 3;
chomp($a);
my $c = substr $b, 3, 5;
chomp($c);
my $d = substr $b, 5, 3;
chomp($d);
 my $noqte=":";
chomp($noqte);
print qq($a$noqte$c$d);
exit;

but I Really Like AutoIt and i want realise it In AuToIT.

Any helps/tips is appreciate.

sorry for my badly english.

[size="5"] [/size]
  • Developers
Posted

Something like:

$a ="%u56e8%u0000%u5300%u5655%u8b57%u246c%u8b18%u"             ; this is my hex string
$s = StringReplace($a, "%u", "")
$s2 = ":"
For $x = 1 to StringLen($s) step 2
    $s2 &= StringMid($s,$x,2) & ":"
Next

Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Posted

$a = "%u56e8%u0000%u5300%u5655%u8b57%u246c%u8b18%u" ; this is my hex string
ConsoleWrite(':' & StringRegExpReplace(StringRegExpReplace($a, "%u", ""), '(..)', '\1:') & @CRLF)

Scripts & functions Organize Includes Let Scite organize the include files

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times

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
×
×
  • Create New...