Re: RegExps in AS
Re: RegExps in AS
- Subject: Re: RegExps in AS
- From: Christopher Stone <email@hidden>
- Date: Sun, 20 Feb 2005 12:53:20 -0600
At 18:35 +0100 02/20/2005, Ihar 'Philips' Filipau wrought:
How do you people do in AS simple things like: strip extension (if
file has one), strip directories from path name (if there anything to
strip), extract extension (if name has one), extract path name (if name
has one), etc.
______________________________________________________________________
Greetings,
I like to use the Satimage osax for regular expressions in Mac OS X.
http://www.satimage.fr/software/en/downloads_osaxen.html
(An osax is an AppleScript extension.)
----------------------------------------------------------------------
set fName to "someFileName.ext"
set fName to change "\\.[a-z]{3}$" into "" in fName with regexp without
case sensitive
----------------------------------------------------------------------
You can also shell out to perl or other languages in Mac OS X.
For a more traditional AppleScript approach you can do something like this:
----------------------------------------------------------------------
set fName to "someFileName.ext"
if character -4 of fName = "." then
set AppleScript's text item delimiters to {"."}
set fName to (text items 1 thru -2 of fName) as string
set AppleScript's text item delimiters to {""}
fName
end if
----------------------------------------------------------------------
Chris
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden
References: | |
| >RegExps in AS (From: "Ihar 'Philips' Filipau" <email@hidden>) |