zaini Posted December 2, 2008 Share Posted December 2, 2008 can somebody help me how to arrange this text??? How to replace this text filesPlayer_1_36.swf C:\Documents and Settings\All user 40 kB044209_734.log C:\Documents and Settings\Logs 40 kBInto this text files40 kB C:\Documents and Settings\All user\Player_1_36.swf 40 kB C:\Documents and Settings\Logs\044209_734.log Link to comment Share on other sites More sharing options...
FireFox Posted December 2, 2008 Share Posted December 2, 2008 (edited) Hi, Use string functions $text="Player_1_36.swf C:\Documents and Settings\All user 40 KB" $String=StringRight($text,6) Msgbox(0,"",$String&StringTrimRight($text,6)) Edited December 2, 2008 by FireFox Link to comment Share on other sites More sharing options...
zaini Posted December 2, 2008 Author Share Posted December 2, 2008 Hi, Use string functions $text="Player_1_36.swf C:\Documents and Settings\All user 40 KB" $String=StringRight($text,6) Msgbox(0,"",$String&StringTrimRight($text,6)) thanx firefox, but it seem just the 40KB is changing the position, Player_1_36.swf C:\Documents and Settings\All user how to change into this? C:\Documents and Settings\All user\Player_1_36.swf sorry coz so many asking.... Link to comment Share on other sites More sharing options...
FireFox Posted December 2, 2008 Share Posted December 2, 2008 thanx firefox, but it seem just the 40KB is changing the position, $text=Player_1_36.swf C:\Documents and Settings\All user $string=StringLeft($text,20) Msgbox(0,"",$string&StringTrimLeft($text,20) how to change into this? C:\Documents and Settings\All user\Player_1_36.swf sorry coz so many asking.... Hum? you want to change all sentence? Nevermind... StringLeft("String",Count) String > your text Count > Number of caracters you want to take from the left Link to comment Share on other sites More sharing options...
zaini Posted December 2, 2008 Author Share Posted December 2, 2008 Hum? you want to change all sentence? Nevermind...StringLeft("String",Count)String > your textCount > Number of caracters you want to take from the leftOh..ok..i try to do it...thanks Link to comment Share on other sites More sharing options...
Moderators big_daddy Posted December 2, 2008 Moderators Share Posted December 2, 2008 This should work. $sText = "044209_734.log C:\Documents and Settings\Logs 40 kB" $sPattern = "(.+\.\H+)(?:\h)(.+\\+\H+)(?:\h)(\d+\hkB)" $aReturn = StringRegExp($sText, $sPattern, 3) If Not @error Then $sNewText = $aReturn[2] & " " & $aReturn[1] & "\" & $aReturn[0] ConsoleWrite($sNewText & @CR) EndIf Link to comment Share on other sites More sharing options...
zaini Posted December 2, 2008 Author Share Posted December 2, 2008 This should work. $sText = "044209_734.log C:\Documents and Settings\Logs 40 kB" $sPattern = "(.+\.\H+)(?:\h)(.+\\+\H+)(?:\h)(\d+\hkB)" $aReturn = StringRegExp($sText, $sPattern, 3) If Not @error Then $sNewText = $aReturn[2] & " " & $aReturn[1] & "\" & $aReturn[0] ConsoleWrite($sNewText & @CR) EndIf amazing big_daddy... you got the exact solution... thanks.... Link to comment Share on other sites More sharing options...
Moderators big_daddy Posted December 2, 2008 Moderators Share Posted December 2, 2008 amazing big_daddy...you got the exact solution...thanks.... You're welcome.The pattern could probably be optimized, but I'm still learning regexp. Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted December 2, 2008 Moderators Share Posted December 2, 2008 (edited) This should work. $sText = "044209_734.log C:\Documents and Settings\Logs 40 kB" $sPattern = "(.+\.\H+)(?:\h)(.+\\+\H+)(?:\h)(\d+\hkB)" $aReturn = StringRegExp($sText, $sPattern, 3) If Not @error Then $sNewText = $aReturn[2] & " " & $aReturn[1] & "\" & $aReturn[0] ConsoleWrite($sNewText & @CR) EndIfGood Job! Another way would be to use RegExReplace for a 1 liner. Local $sText = "044209_734.log C:\Documents and Settings\Logs 40 kB" Local $s_pattern = "(?i)(.*?)(\s+)(\w:\\.*?)(\s+)(\d+\s+(?:mb|kb))" ; Working backwards parenthesis 5 group 1st + space + parenthesis 3 group + slash + parenthesis 1 group Local $s_out = StringRegExpReplace($sText, $s_pattern, "\5 \3\\\1") ConsoleWrite($s_out & @CRLF) Edit: After conferring with big_daddy on the drive letter, and thinking about possible network options, I think this is probably the best method: Local $sText = "044209_734.log C:\Documents and Settings\Logs 40 kB" Local $s_pattern = "(?i)(.*?)(\s+)((?:[a-z]:\\|\\\\).*?)(\s+)(\d+\s+(?:mb|kb)\z)" ; Working backwards parenthesis 5 group 1st + space + parenthesis 3 group + slash + parenthesis 1 group Local $s_out = StringRegExpReplace($sText, $s_pattern, "\5 \3\\\1") ConsoleWrite($s_out & @CRLF) Edited December 2, 2008 by SmOke_N Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. 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