Jump to content

Recommended Posts

Posted

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?

Posted

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)

 

Posted

@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:

 

Posted

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)

 

 

image.jpeg.9f1a974c98e9f77d824b358729b089b0.jpeg Chimp

small minds discuss people average minds discuss events great minds discuss ideas.... and use AutoIt....

Posted

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)

 

,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-.
|(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/
(_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_)
| | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) (
| | | | |)| | \ / | | | | | |)| | `--. | |) \ | |
`-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_|
'-' '-' (__) (__) (_) (__)

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
  • Recently Browsing   0 members

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