jeantje Posted March 1, 2009 Share Posted March 1, 2009 (edited) Ok i have a problem i have a file like this yfduÿxxfxxdfhjrkfhÿÿumHELLOÿgffdgdfÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ and i want to strip those last characters but these are random sometimes it are 10 sometimes it are 10000 and i want that the ÿ in the text stay there Edited March 1, 2009 by jeantje Link to comment Share on other sites More sharing options...
James Posted March 1, 2009 Share Posted March 1, 2009 Dim $string = "yfduÿxxfxxdfhjrkfhÿÿumHELLOÿgffdgdfÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ" Dim $search = "ÿ" $strSplit = StringSplit($string, $search); Forgive me Jos;) $newString = StringTrimRight($string, $strSplit[0]) ConsoleWrite($newString & @CRLF) Better ways to do it though. Blog - Seriously epic web hosting - Twitter - GitHub - Cachet HQ Link to comment Share on other sites More sharing options...
foster74 Posted March 1, 2009 Share Posted March 1, 2009 (edited) Here is a way, but I am a noob, so if you wait a few minutes I'm sure you'll get better answers =) $string="yfduÿxxfxxdfhjrkfhÿÿumHELLOÿgffdgdfÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ" While 1 $StringRight = StringRight($string, 1) If $StringRight = "ÿ" Then $string = StringTrimRight($string, 1) Else Exitloop EndIf Wend msgbox(0,"Test", "$string = " & $string) Edit: It didn't even take a couple minutes =/ Edited March 1, 2009 by foster74 Link to comment Share on other sites More sharing options...
jeantje Posted March 1, 2009 Author Share Posted March 1, 2009 (edited) but the next problem is that it's a 64 mb nds rom and i want to strip of those characters and then write it back but if i use this #include <String.au3> #include <File.au3> Dim $string = FileRead(@ScriptDir & "\1.nds") $strSplit = StringSplit($string, "ÿ")) $newString = StringTrimRight($string, $strSplit[0]) FileWrite(@ScriptDir & "\2.nds",$newString)oÝ÷ Ú+«!zƧwbëaÊ'y«¢+Ø¥¹±Õ±ÐíMÑÉ¥¹¹ÔÌÐì(¥¹±Õ±Ðí¥±¹ÔÌÐì(ÀÌØí!¹±ô¥±=Á¸ ÅÕ½ÐìĹ¹ÌÅÕ½Ðì°ÅÕ½ÐíÈÅÕ½Ðì¤(ÀÌØíMÑÉ¥¹ô¥±I ÀÌØí!¹±¤()]¡¥±Ä(ÀÌØíMÑÉ¥¹I¥¡ÐôMÑÉ¥¹I¥¡Ð ÀÌØíMÑÉ¥¹°Ä¤(%ÀÌØíMÑÉ¥¹I¥¡ÐôÅÕ½ÐïüÅÕ½ÐìQ¡¸(ÀÌØíÍÑÉ¥¹ôMÑÉ¥¹QÉ¥µI¥¡Ð ÀÌØíMÑÉ¥¹°Ä¤(±Í(á¥Ñ±½½À(¹%)]¹()¥±]É¥Ñ ÅÕ½Ðìȹ¹ÌÅÕ½Ðì°ÀÌØíMÑÉ¥¹ uses way too high cpu and memory Edited March 1, 2009 by jeantje Link to comment Share on other sites More sharing options...
James Posted March 1, 2009 Share Posted March 1, 2009 Open the file first. FileOpen. Plus it's 64MB it's big, AutoIt will slow when doing that. Blog - Seriously epic web hosting - Twitter - GitHub - Cachet HQ Link to comment Share on other sites More sharing options...
foster74 Posted March 1, 2009 Share Posted March 1, 2009 This should be faster; $string="yfduÿxxfxxdfhjrkfhÿÿumHELLOÿgffdgdfÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ" $StringReplace = StringReplace($string, "ÿ", "") $StringRight = StringRight($StringReplace, 1) $StringInStr = StringInStr($string, $StringRight, 0, -1) $string = StringLeft($string, $StringInStr) ConsoleWrite($string & @CRLF) Link to comment Share on other sites More sharing options...
exodius Posted March 1, 2009 Share Posted March 1, 2009 (edited) See revised post below... Edited March 1, 2009 by exodius Link to comment Share on other sites More sharing options...
jeantje Posted March 1, 2009 Author Share Posted March 1, 2009 it only creates ANIMAL CROSSADMP01 from ANIMAL CROSSADMP01 @ Xì 8 8ø ø ; ×# d, `X ø ð% i]X X8 8ᨠ@ $ÿ®Qi¢!= ä $À!£R¾ Î FJJø'1ìXÇè3ãοôßÎK ÁVÀr§üMs£ÊaX£'üv#Ça®V¿8 @§ýÿRþo0ñûÀ`Ö%©c¾N8âù¢4ÿ»>Dx Ë:eÀ|cð<¯Ö%ä8 ¬r!ÔøVϹF Link to comment Share on other sites More sharing options...
exodius Posted March 1, 2009 Share Posted March 1, 2009 (edited) Is this better? Faster Yet: $string="yfduÿxxfxxdfhjrkfhÿÿumHELLOÿgffdgdfÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ" MsgBox (0, "", StringRegExpReplace($string, "ÿ{1,10000}\s|ÿ{1,10000}\z", "")) #include <String.au3> #include <File.au3> $string = FileRead(@ScriptDir & "\1.nds") FileWrite(@ScriptDir & "\2.nds",StringRegExpReplace($string, "ÿ{1,10000}\s|ÿ{1,10000}\z", "")) *Edit - Changed to ÿ{1,10000}\s|ÿ{1,10000}\z Edited March 1, 2009 by exodius Link to comment Share on other sites More sharing options...
Robjong Posted March 1, 2009 Share Posted March 1, 2009 (edited) Hey, $string="yfduÿxxfxxdfhjrkfhÿÿumHELLOÿgffdgdfÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ" MsgBox (0, "", StringRegExpReplace($string, "ÿ{1,10000}\s", ""))oÝ÷ Ûú®¢×+0Yg¢Ü(®FÞq«¬zØ^è¬)iǶØ^zwm+,¥w +'íçâéh¢K%Gë-®)à{ayìZ^jëh×6#include <File.au3> ;~ $sString = FileRead(@ScriptDir & "\1.nds") $sString = "yfduÿxxfxxdfhjrkfhÿÿumHELLOÿgffdgdfÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ" $sString = StringRegExpReplace($sString, "ÿ+\s*\z", "") ;~ FileWrite(@ScriptDir & "\2.nds", $sString) MsgBox (0, "Stripped trailing ÿ", $sString) "ÿ+\s*\z" ÿ+ to match one or more ÿ characters, \s* to match none or unlimited spaces, \z match at the end of the string Edited March 1, 2009 by Robjong Link to comment Share on other sites More sharing options...
exodius Posted March 1, 2009 Share Posted March 1, 2009 (edited) Ah, fair enough, that's true for the MsgBox example, but it should actually work better for the second example of doing a Replace on the whole file. When I ran it against that following, which I assumed would be representative of what his file would look like (that is, more than one line): yfduÿxxfxxdfhjrkfhÿÿumHELLOÿgffdgdfÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ yfduÿxxfxxdfhjrkfhÿÿumHELLOÿgffdgdfÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ yfduÿxxfxxdfhjrkfhÿÿumHELLOÿgffdgdfÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ yfduÿxxfxxdfhjrkfhÿÿumHELLOÿgffdgdfÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ yfduÿxxfxxdfhjrkfhÿÿumHELLOÿgffdgdfÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ yfduÿxxfxxdfhjrkfhÿÿumHELLOÿgffdgdfÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ Here's what I get with: MsgBox (0, "", StringRegExpReplace(ClipGet(), "ÿ+\s*\z", "")) yfduÿxxfxxdfhjrkfhÿÿumHELLOÿgffdgdfÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ yfduÿxxfxxdfhjrkfhÿÿumHELLOÿgffdgdfÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ yfduÿxxfxxdfhjrkfhÿÿumHELLOÿgffdgdfÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ yfduÿxxfxxdfhjrkfhÿÿumHELLOÿgffdgdfÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ yfduÿxxfxxdfhjrkfhÿÿumHELLOÿgffdgdfÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ yfduÿxxfxxdfhjrkfhÿÿumHELLOÿgffdgdf Here's what I get with: MsgBox (0, "", StringRegExpReplace(ClipGet(), "ÿ{1,10000}\s|ÿ{1,10000}\z", "")) yfduÿxxfxxdfhjrkfhÿÿumHELLOÿgffdgdf yfduÿxxfxxdfhjrkfhÿÿumHELLOÿgffdgdf yfduÿxxfxxdfhjrkfhÿÿumHELLOÿgffdgdf yfduÿxxfxxdfhjrkfhÿÿumHELLOÿgffdgdf yfduÿxxfxxdfhjrkfhÿÿumHELLOÿgffdgdf yfduÿxxfxxdfhjrkfhÿÿumHELLOÿgffdgdf (I did go ahead and modify it because without the \z or statement it was leaving off the last line.) Edited March 1, 2009 by exodius Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now