Andre Celie Posted May 13, 2008 Share Posted May 13, 2008 Is it possible to split a file name which contains the following structure? ThisIsATest, which needs to be like this: This Is A Test Same problem I have when there is a number within the filename like this 5ClocksAround : 5 Clocks Around Thanx Link to comment Share on other sites More sharing options...
smashly Posted May 13, 2008 Share Posted May 13, 2008 (edited) Hi, I'm not sure how to do it, but I think StringRegExpReplace() function could do it with the right expression/pattern match.Here's a crude example using StringReplace() instead..#include <GUIConstantsEx.au3> $hGui = GUICreate("Add Spaces", 350, 300) GUICtrlCreateGroup("Input text to space", 10, 10, 330, 45) $Input = GUICtrlCreateInput("IAmAStringThatShouldHave7Spaces", 20, 25, 270, 20) $Button = GUICtrlCreateButton("Go", 300, 25, 30, 20) GUISetState(@SW_SHOW, $hGui) While 1 $msg = GUIGetMsg() Switch $msg Case $GUI_EVENT_CLOSE Exit Case $Button Local $GCR, $sTmp $GCR = GUICtrlRead($Input) For $i = 1 To StringLen($GCR) If StringIsUpper(StringMid($GCR, $i, 1)) Or StringIsInt(StringMid($GCR, $i, 1)) Then $sTmp &= " " & StringMid($GCR, $i, 1) Else $sTmp &= StringMid($GCR, $i, 1) EndIf Next GUICtrlSetData($Input, $sTmp) EndSwitch WEnd Cheers Edited May 13, 2008 by smashly Link to comment Share on other sites More sharing options...
weaponx Posted May 13, 2008 Share Posted May 13, 2008 (edited) I don't understand if you want an array to be retrieved like StringSplit, or if you just want spaces put in the proper places. Anyways...This will just insert spaces after each word (uncomment the second line to see how it works with numbers):$string = "ThisIsATest" ;$string = "5ClocksAround" $out = StringRegExpReplace($string, '[A-Z0-9][^A-Z]*', '$0 ') Consolewrite($out & @CRLF)This will return an array of all words:#include<Array.au3> $string = "ThisIsATest" ;$string = "5ClocksAround" $result = StringRegExp($string, '[[:alnum:]][^[:upper:]]*', 3) _ArrayDisplay($result, "Letter pairs, split by upper case letters")I also wrote this _StringSplitRegExp function which may help you in the future:http://www.autoitscript.com/forum/index.ph...;hl=stringsplit Edited May 13, 2008 by weaponx Link to comment Share on other sites More sharing options...
Andre Celie Posted May 14, 2008 Author Share Posted May 14, 2008 (edited) Thanx just needed 2 codelines for my script and it worked. Only a smal thing the last Character is a space, don't know kow te solve this Thanx Edited May 14, 2008 by Andre Celie 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