Tony007 Posted June 9, 2019 Share Posted June 9, 2019 Hello, I have a certain number of words (10 - 20 words) separated by a comma. What can I do that only the first 5 words remain, the rest should be deleted? Link to comment Share on other sites More sharing options...
FrancescoDiMuro Posted June 9, 2019 Share Posted June 9, 2019 @Tony007 Post an example and what you have tried so far Click here to see my signature: Spoiler ALWAYS GOOD TO READ: Forum Rules Forum Etiquette Link to comment Share on other sites More sharing options...
Tony007 Posted June 9, 2019 Author Share Posted June 9, 2019 Sorry but I have no examples, I searched on google and autoit help, but I do not know what to look for. Link to comment Share on other sites More sharing options...
Tony007 Posted June 9, 2019 Author Share Posted June 9, 2019 Do you know what commands can help me? Link to comment Share on other sites More sharing options...
1957classic Posted June 9, 2019 Share Posted June 9, 2019 Look up StringSplit in the help files. That should get you started. Link to comment Share on other sites More sharing options...
FrancescoDiMuro Posted June 9, 2019 Share Posted June 9, 2019 28 minutes ago, Tony007 said: Sorry but I have no examples So you are working on nothing, since you have nothing to try the script with. Click here to see my signature: Spoiler ALWAYS GOOD TO READ: Forum Rules Forum Etiquette Link to comment Share on other sites More sharing options...
Tony007 Posted June 9, 2019 Author Share Posted June 9, 2019 I need something like this, but the first 5 words should stay and not the characters. #include <MsgBoxConstants.au3> Local $sString = StringLeft("Mon,Tues,Wed,Thur,Fri,Sat,Sun", 5) ; Retrieve 5 characters from the left of the string. MsgBox($MB_SYSTEMMODAL, "", "The 5 leftmost characters are: " & $sString) Link to comment Share on other sites More sharing options...
FrancescoDiMuro Posted June 9, 2019 Share Posted June 9, 2019 @Tony007 If you need to split those strings in different ones, then you can use StringSplit() with the comma set as separator, which will return an array of eight (seven, if the parameter $STR_NOCOUNT is set), in which each element represents a day of the week. From there, you can do whatever you want with that array Click here to see my signature: Spoiler ALWAYS GOOD TO READ: Forum Rules Forum Etiquette Link to comment Share on other sites More sharing options...
Gianni Posted June 9, 2019 Share Posted June 9, 2019 ok what FrancescoDiMuro sayd, or, using another way, you could also combine togheter StringLeft and StringInString so that StringInString can find the position of the fifth comma and keep all chars on the left up to that position less 1 #include <MsgBoxConstants.au3> $sList = "Mon,Tues,Wed,Thur,Fri,Sat,Sun" $iWords = 5 ; words to keep on the left Local $sString = StringLeft($sList, StringInStr($sList & ',', ',', 1, $iWords) - 1) MsgBox($MB_SYSTEMMODAL, "", "The " & $iWords & " leftmost words are: " & $sString) Chimp small minds discuss people average minds discuss events great minds discuss ideas.... and use AutoIt.... Link to comment Share on other sites More sharing options...
iamtheky Posted June 9, 2019 Share Posted June 9, 2019 Also consider that since you know what you want, you can just ignore the other stuff altogether #include<array.au3> local $aList[] = ["Mon","Tues","Wed","Thur","Fri","Sat","Sun"] _ArrayDisplay($aList , "The first 5 items" , 4) FrancescoDiMuro 1 ,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-. |(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/ (_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_) | | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) ( | | | | |)| | \ / | | | | | |)| | `--. | |) \ | | `-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_| '-' '-' (__) (__) (_) (__) 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