Jump to content

extract a string


pdug175
 Share

Recommended Posts

Hi I want to extract the time from a number of strings like the one below:

Belfast (NI) 20th Feb - 21:06 Suspended

The problem that I have is that the strings don't follow any uniform pattern, so to strip x chars from the left or the right, or use stringreplace to remove Suspended and then grab the 5 rightmost characters wouldn't work as each string is slightly different. Would there be a way to strip everything up to and including the - char (as the time is always proceeded with a -) and then use Stringleft to determine the time?

Link to comment
Share on other sites

You could do stringleft or stringtrimleft in a for loop until the - is reached, or you could do it an easier method and use StringSplit.

$SplitArray = StringSplit("Belfast (NI) 20th Feb - 21:06 Suspended", " - ", 1)

This will return an array containing the split string. $SplitArray[0] will equal 2 (number of sections), $SplitArray[1] will be the left section up to the split, and $SplitArray[2] will be "21:06 Suspended" - you can get the time from there.

Link to comment
Share on other sites

Thanks again great help here on these forums.

Think it's a bit rude of me not to introduce myself! My name's Paul I'm from the UK, I've used autoit before in the past and I'm currently working on a script to collate and analyse data from my betfair account. I have done abit of programming in the past and thought I'd give this ago while I have a bit of time in the evenings. :o

Link to comment
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
 Share

  • Recently Browsing   0 members

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