Jump to content

How to arrange text


zaini
 Share

Recommended Posts

can somebody help me how to arrange this text???

:)

How to replace this text files

Player_1_36.swf C:\Documents and Settings\All user 40 kB

044209_734.log C:\Documents and Settings\Logs 40 kB

Into this text files

40 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

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 by FireFox
Link to comment
Share on other sites

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

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

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

  • Moderators

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
Good 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 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

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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...