Sign in to follow this  
Followers 0
Fire

Need Tips about string

5 posts in this topic

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]

Share this post


Link to post
Share on other sites



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


Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

Thanks you very much Jos.Great++ Edited by Sh3llC043r

[size="5"] [/size]

Share this post


Link to post
Share on other sites

$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

Share this post


Link to post
Share on other sites

Thanks you too Xenobiologist i test it. Great ++

Thanks to all again.


[size="5"] [/size]

Share this post


Link to post
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
Sign in to follow this  
Followers 0