Sign in to follow this  
Followers 0
zaini

How to arrange text

9 posts in this topic

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


Share this post


Link to post
Share on other sites



#2 ·  Posted (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 by FireFox

 

OS : Win XP SP2 (32 bits) / Win 7 SP1 (64 bits) / Win 8 (64 bits) | Autoit version: latest stable / beta.
Hardware : Intel(R) Core(TM) i5-2400 CPU @ 3.10Ghz / 8 GiB RAM DDR3.

My UDFs : Skype UDF | TrayIconEx UDF | GUI Panel UDF | Excel XML UDF | Is_Pressed_UDF

My Projects : YouTube Multi-downloader | FTP Easy-UP | Lock'n | WinKill | AVICapture | Skype TM | Tap Maker | ShellNew | Scriptner | Const Replacer | FT_Pocket | Chrome theme maker

My Examples : Capture toolIP Camera | Crosshair | Draw Captured Region | Picture Screensaver | Jscreenfix | Drivetemp | Picture viewer

My Snippets : Basic TCP | Systray_GetIconIndex | Intercept End task | Winpcap various | Advanced HotKeySet | Transparent Edit control

 

Share this post


Link to post
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.... :)


Share this post


Link to post
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


 

OS : Win XP SP2 (32 bits) / Win 7 SP1 (64 bits) / Win 8 (64 bits) | Autoit version: latest stable / beta.
Hardware : Intel(R) Core(TM) i5-2400 CPU @ 3.10Ghz / 8 GiB RAM DDR3.

My UDFs : Skype UDF | TrayIconEx UDF | GUI Panel UDF | Excel XML UDF | Is_Pressed_UDF

My Projects : YouTube Multi-downloader | FTP Easy-UP | Lock'n | WinKill | AVICapture | Skype TM | Tap Maker | ShellNew | Scriptner | Const Replacer | FT_Pocket | Chrome theme maker

My Examples : Capture toolIP Camera | Crosshair | Draw Captured Region | Picture Screensaver | Jscreenfix | Drivetemp | Picture viewer

My Snippets : Basic TCP | Systray_GetIconIndex | Intercept End task | Winpcap various | Advanced HotKeySet | Transparent Edit control

 

Share this post


Link to post
Share on other sites

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

Oh..ok..

i try to do it...thanks :)


Share this post


Link to post
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

Share this post


Link to post
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.... :)


Share this post


Link to post
Share on other sites

amazing big_daddy...

you got the exact solution...

thanks.... :)

You're welcome.

The pattern could probably be optimized, but I'm still learning regexp.

Share this post


Link to post
Share on other sites

#9 ·  Posted (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)
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.

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  
Followers 0