Jump to content
Sign in to follow this  
damian666

how to replace a unknown piece of a string?

Recommended Posts

hi guys, i want to know if anybody has a idea to replace a string in a string, without knowing that string...

yeah, sounds weird huh?

i know, thats why i cant figure it out, ofcourse i tried stringreplace, but for that i have to know the exact string.

and i also must be sure it is replaced on the right spot.

so i thought about someting that will enable me to define the right spot by counting characters.

lets say i have to start at the 68 place and replace 2 characters there.

how can i let my replace script start there? and only replace 2 characters and leave the rest of the string intact?

any help is welcome :)

Damian666

Share this post


Link to post
Share on other sites

Hey

i don't have autoit here, but i love to help people.

maybe you mean StringInStr(). This command finds a string INSIDE of a string.

Global $randomstring = "bladieblabla"
Global $searchstr = "die"

$var = StringInStr($randomstring, $searchstr)

here will $var be 4 where 'die' lies.

hope that helps :)

immense

Share this post


Link to post
Share on other sites

well, thatys a start, but you have told the script that it looks for "die", and thats the problem...

i dont know where i am looking for , only with what i want to replace it.

see the weird stuff i am in?? :)

a little more info maybe, i open up a file in binary mode and read it in as string.

then i have to replace certain hexcodes, which is the string... but because i am dealing with multiple languages

the string is not the same all the time...

thats the problem i am encountering here.

but still thanx man :(

Damian666

Share this post


Link to post
Share on other sites

huhh...

i cannot think of a situation where you know what you want to replace and where you dont know what to replace...

well, looking at the part you said:

so i thought about someting that will enable me to define the right spot by counting characters.
lets say i have to start at the 68 place and replace 2 characters there.

Now i have made an example what i think that might be useful for that:

$FULLSTRING =   "BLABLABLAHEXHEXHEXHEXWAITINGFORSIXTYEIGHTCHARACTERSCHEESECHEDDARWITHBUTTERANDCHEESEANDWHATEVERILOVEMYCATSMILE"

$leftpart   =   StringLeft($FULLSTRING, 68)
;$center        =   StringMid($FULLSTRING, 68, 2)
$rightpart  =   StringRight($FULLSTRING, StringLen($FULLSTRING)-70)

$replacement=   "REPLACEMENT"
$NEWSTRING  =   $leftpart&$replacement&$rightpart

MsgBox(0, "", $center)

text is a bit long, but its longer than 68 and thats the point :)

immense

Share this post


Link to post
Share on other sites

well, that seems to work wit your example, when i replace the $center var with the $newstring var.

and you want to know what situation calls for this?

i tell you, i have made a uxtheme patcher for the new XP sp3, i got a lot of help allready here, but the way we patched it

was faulty, not the autoit code, but my hexcode was wrong, it turns out the hexdata is different on other languages.

but because i cant check every single language for the right hexdata, i have to get a way to do it with this way :)

and because the patcher is downloaded more then 10.000 times allreday, it is very important i get i right this time.

and trust me, you will be credited in the aboutbox when this works :(

i will report back with the news man, thanx a lot

damian666

Share this post


Link to post
Share on other sites

well, that seems to work wit your example, when i replace the $center var with the $newstring var.

and you want to know what situation calls for this?

i tell you, i have made a uxtheme patcher for the new XP sp3, i got a lot of help allready here, but the way we patched it

was faulty, not the autoit code, but my hexcode was wrong, it turns out the hexdata is different on other languages.

but because i cant check every single language for the right hexdata, i have to get a way to do it with this way :(

and because the patcher is downloaded more then 10.000 times allreday, it is very important i get i right this time.

and trust me, you will be credited in the aboutbox when this works :D

i will report back with the news man, thanx a lot

damian666

Why not take a patched version of uxtheme.dll, and compare the hex data with an unpached one, and then replace whatever is changed?

Better yet, why not just pack the patched uxtheme.dll into your script and overwrite the unpatched one :)

Share this post


Link to post
Share on other sites

Why not take a patched version of uxtheme.dll, and compare the hex data with an unpached one, and then replace whatever is changed?

i did man :)

Better yet, why not just pack the patched uxtheme.dll into your script and overwrite the unpatched one

would result in too many language versions man, :(

Damian666

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  

×
×
  • Create New...