david1337

Stringsplit?

11 posts in this topic

Hi

With this code I can convert a string into Hex:
 

$String = "tdmsl"
$Hex = StringRegExpReplace(StringTrimLeft(StringToBinary($String), 2),"(..)","\1 ")
ConsoleWrite($Hex)

The result in this example is 74 64 6D 73 6C

But how can I create a result with 00 between each "letter" so it would give this result: 74 00 64 00 6D 00 73 00 6C 00

Share this post


Link to post
Share on other sites



$String = "tdmsl"
$Hex = StringRegExpReplace(StringTrimLeft(StringToBinary($String), 2),"(..)","\1 00 ")
ConsoleWrite($Hex)

 


,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-.
|(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/
(_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_)
| | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) (
| | | | |)| | \ / | | | | | |)| | `--. | |) \ | |
`-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_|
'-' '-' (__) (__) (_) (__)

Share this post


Link to post
Share on other sites

Can't believe it was that easy... :>

Thanks boththose !

Share this post


Link to post
Share on other sites

And if I want no spaces at all like: 740064006D0073006C00

:>?

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

Then just remove the space after \1

Sorry, I didn't notice that the \1 00 becomes \100. In this case, you have to use ${1} instead of \1

Another way, using \K (avoid the use of \1 or $1)

$Hex = StringRegExpReplace(StringTrimLeft(StringToBinary($String), 2),"..\K","00")

And another one, without using StringTrimLeft :

$Hex = StringRegExpReplace(StringToBinary($String), "(?:^0x|\G)([[:xdigit:]]{2})", "${1}00")


 

Edited by jguinch

Share this post


Link to post
Share on other sites
$String = "tdmsl"
$Hex = StringStripWS(StringRegExpReplace(StringTrimLeft(StringToBinary($String), 2),"(..)","\1 00 ") , 8)
ConsoleWrite($Hex)

 


,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-.
|(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/
(_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_)
| | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) (
| | | | |)| | \ / | | | | | |)| | `--. | |) \ | |
`-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_|
'-' '-' (__) (__) (_) (__)

Share this post


Link to post
Share on other sites

My friends, aren't you making your life more complicated than it should be?

Want the UTF-16 binary image of a string?

$String = "€tdmsl"
$Hex = StringTrimLeft(StringToBinary($String, 2) & "", 2)
ConsoleWrite($Hex & @LF)

Try previous versions with non-ANSI characters, just to scratch heads.


This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.
Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe here
RegExp tutorial: enough to get started
PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.
SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.
An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.
SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)
A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!
SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)

Share this post


Link to post
Share on other sites

#9 ·  Posted (edited)

Thanks guys!

Just tested them individually, and they all worked actually :)

Edited by david1337

Share this post


Link to post
Share on other sites

My friends, aren't you making your life more complicated than it should be?

Want the UTF-16 binary image of a string?

$String = "€tdmsl"
$Hex = StringTrimLeft(StringToBinary($String, 2) & "", 2)
ConsoleWrite($Hex & @LF)

Try previous versions with non-ANSI characters, just to scratch heads.

Why didn't you just hex your binary?


♡♡♡

.

eMyvnE

Share this post


Link to post
Share on other sites

Yes that's true, as well and more simply.


This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.
Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe here
RegExp tutorial: enough to get started
PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.
SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.
An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.
SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)
A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!
SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)

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