cookiemonster Posted July 8, 2013 Share Posted July 8, 2013 Hi, Ive got a folder called '123 - abc' I need to read this folder name then remove anything after the first white space and leave this in a varible. So it would end up as: $Varible = "123" Any ideas? Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted July 8, 2013 Moderators Share Posted July 8, 2013 quinnj09, Any ideas?Lots - but what have you tried that has not worked? And how do you determine the folder name initially? Selected from a list? Matched in a search? M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
TheSaint Posted July 8, 2013 Share Posted July 8, 2013 Same here, show us what code you've come up with so far, and we'll help fill in any missing gaps you may have. Make sure brain is in gear before opening mouth! Remember, what is not said, can be just as important as what is said. Spoiler What is the Secret Key? Life is like a Donut If I put effort into communication, I expect you to read properly & fully, or just not comment. Ignoring those who try to divert conversation with irrelevancies. If I'm intent on insulting you or being rude, I will be obvious, not ambiguous about it. I'm only big and bad, to those who have an over-active imagination. I may have the Artistic Liesense to disagree with you. TheSaint's Toolbox (be advised many downloads are not working due to ISP screwup with my storage) Link to comment Share on other sites More sharing options...
cookiemonster Posted July 10, 2013 Author Share Posted July 10, 2013 Sorry for the slow reply guys, had some progress, im taking the name from an input label, it then removes any letters, so it does what I wanted it to do... well at least it did until I cam across this issue: label might have in it '1234 - dog' which is fine because this then gives be '1234' which then is changed to 'fix1234' however yesterday I had one which was '5678 - 100 monkey' so this should of turned out to be '5678' which is then changed to 'fix5678' however as im sure youve already guess I actually got '5678100' then 'fix5678100' Now I cant split the string and say take the first four numbers, because its not always four, sometimes its only three, sometimes its as many as nine, I basically need it to chuck away everything after the first space, this would then leave me with just '5678' in the last example. $projectnumber = GUICtrlRead($projectname) $fix_id_value=StringRegExpReplace($fixnumber,"\D+","") GUICtrlSetData($fix_id, "fix" & $fix_id_value) Link to comment Share on other sites More sharing options...
Moderators Solution Melba23 Posted July 10, 2013 Moderators Solution Share Posted July 10, 2013 cookiemonster,This SRER works for me:Global $aList[3] = ["1234 - dog", "5678 - 100 monkey", "123456789 - 500 pig"] For $i = 0 To 2 $sRet = StringRegExpReplace($aList[$i], "(\d+)\s.*", "fix$1") ConsoleWrite($sRet & @CRLF) NextDecode:(\d+) ; Look for a series of digits and capture it \s ; Until we reach a space .* ; Followed by the rest of the line fix$1 ; Return the captured group prefixed with fixAll clear? M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
LeppyR64 Posted July 10, 2013 Share Posted July 10, 2013 Would StringSplit($fixstring," ") perform the function you're looking for? The first element in the returned array would be your result. Link to comment Share on other sites More sharing options...
cookiemonster Posted July 10, 2013 Author Share Posted July 10, 2013 Melba23 that works great cheers! LeppyR64, now I feel very stupid! I almost gave myself the answer talking about not being able to use split string, stupid me didnt think of getting it to split it at the first space. Either way cheers to both of ya!! Link to comment Share on other sites More sharing options...
TheSaint Posted July 10, 2013 Share Posted July 10, 2013 Either split it at the first space ..... or the dash and then remove all spaces from the end result using StringStripWS. The beauty with the second method, is that it accounts for a circumstance where the space may be missing ... though I'm not sure whether that is at all possible, so may be entirely unnecessary. Make sure brain is in gear before opening mouth! Remember, what is not said, can be just as important as what is said. Spoiler What is the Secret Key? Life is like a Donut If I put effort into communication, I expect you to read properly & fully, or just not comment. Ignoring those who try to divert conversation with irrelevancies. If I'm intent on insulting you or being rude, I will be obvious, not ambiguous about it. I'm only big and bad, to those who have an over-active imagination. I may have the Artistic Liesense to disagree with you. TheSaint's Toolbox (be advised many downloads are not working due to ISP screwup with my storage) 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