Go Back   MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Reply
 
Thread Tools Search this Thread Display Modes
Old Aug 5, 2013, 01:53 PM   #1
wild4life2013
macrumors newbie
 
Join Date: Mar 2013
Applescript Is there a way to search for a time or date withi text

I have a script that has a repeat loop that set a variable to some text I would like to be able to search that text and different information out. like any date it contains or times.

thanks in advance for any help
wild4life2013 is offline   0 Reply With Quote
Old Aug 7, 2013, 11:10 AM   #2
superscape
macrumors regular
 
Join Date: Feb 2008
Location: Yorkshire, UK
Hi,

You might want to look at the regular expressions functionality within Satimage.osax

http://www.satimage.fr/software/en/d...on_osaxen.html

Hope that's some help
superscape is offline   1 Reply With Quote
Old Aug 7, 2013, 04:06 PM   #3
wild4life2013
Thread Starter
macrumors newbie
 
Join Date: Mar 2013
thanks superscape ill check it out
wild4life2013 is offline   0 Reply With Quote
Old Sep 4, 2013, 05:30 AM   #4
wild4life2013
Thread Starter
macrumors newbie
 
Join Date: Mar 2013
I extracted the time using the code below
Code:
set theText to "test of extracting the time 19:30 from all of the other text"
set theOffset to offset of ":" in theText
set num to theOffset - 2
set thetime to text (theOffset + 2) thru num of theText
this works well.
couldn't work it out with the Satimage OSAX but have used it in other scripts.
wild4life2013 is offline   0 Reply With Quote
Old Sep 20, 2013, 06:39 AM   #5
superscape
macrumors regular
 
Join Date: Feb 2008
Location: Yorkshire, UK
Regexp

Hi,

Yep, that would work if you're confident that you'll never get text like:

"Here foo:bar blah blah blah"

In which case, your script would get a false match of "oo:ba" which clearly isn't a time. If you were to use Satimage OSAX then you could use a regular expression such as:

Code:
set theText to "test of extracting the time 19:30 from all of 19 the other text"

set theFoundTimes to find text "[0-9]{2}:[0-9]{2}" in theText with all occurrences and regexp
Which would match any two digits, a colon then another two digits. You'd probably want to tweak the regular expression to avoid things like 1234:34567 (as an example) if there's a chance they might appear in your text. Writing clever regular expressions is not my strong point!

Hope that's some help,

Rob
superscape is offline   0 Reply With Quote
Old Sep 20, 2013, 01:35 PM   #6
wild4life2013
Thread Starter
macrumors newbie
 
Join Date: Mar 2013
Thanks superscape (Rob) that great thanks
wild4life2013 is offline   0 Reply With Quote

Reply
MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Similar Threads
thread Thread Starter Forum Replies Last Post
Append Text to Text File in Applescript BobRon Mac Programming 2 Mar 23, 2014 03:52 PM
Applescript help: creating a date from text in Outlook email Rossdillon Mac Programming 1 Feb 22, 2014 05:48 PM
Search text ("Search Forums...") does not get cleared - Java Script? smithrh Site and Forum Feedback 5 Oct 1, 2013 12:41 PM
Twitter search: search all tweets from @example in time range of one week Quotenfrau Community Discussion 1 Mar 29, 2013 10:22 AM
Applescript to Generate text based on day of the week and time. kdpyke Mac Programming 1 Sep 14, 2012 05:34 PM

Forum Jump

All times are GMT -5. The time now is 03:17 AM.

Mac Rumors | Mac | iPhone | iPhone Game Reviews | iPhone Apps

Mobile Version | Fixed | Fluid | Fluid HD
Copyright 2002-2013, MacRumors.com, LLC