Re: Native AS or grep via do shell script?
Re: Native AS or grep via do shell script?
- Subject: Re: Native AS or grep via do shell script?
- From: Jakob Peterhänsel <email@hidden>
- Date: Fri, 29 Oct 2004 12:43:39 +0200
Hi,
That perl stuff seems to work, but I can't get it to return stuff where the matching is over multiple lines.
Consider the text:
------Email Body--------------
Entry text line here:
Area Discription
In periode from
dd-mm-yyyy hh:mm
to
dd-mm-yyyy hh:mm
Bla.. bla...
-------Email body end---------
Now this code works fine:
set "perl -ne 'print if s/(Are\\w+)/$1/;'"
set do shell script "echo " & quoted form & " | " & cliCmd
--> Area Discription
If I introduce some newline matching, it fails, like:
set "perl -ne 'print if s/\\r(\\w+)/$1/;'"
I'm really puzzled over this, as the perlre man-page say's it should be working. Even using \n gives the same no-match.
If I use
quoted form cliCmd it errors with "..file not found" - seems like it thinks the
cliCmd is then a fileref...
set "perl -ne 'print if /[0-9][0-9]-[0-9][0-9]-[0-9][0-9][0-9][0-9]/;'"
returns the two lines with the date strings in them.
Now, if only we could get the BBEdit grep engine into AppleScript.... ;-), as I would like to avoid opening windows in BBE just to search a mail body text...
Hmm....
____________________________________________
Jakob Peterhänsel
Network Consultant
Tel: +45 7022 1014
Fax: +45 7022 1013
Mob: +45 22 68 49 61
email@hidden
www.NetPoint.com
On 27. okt 2004, at 22:22, Christopher Nebel wrote:
On Oct 27, 2004, at 3:00 AM, Jakob Peterhänsel wrote:
Now, if only the CLI grep was as flexible as the one in BBEdit... :-/
Try using egrep or grep -E -- that turns on the extended regular expression support. For instance, under egrep, your pattern could be equivalently written like this:
[0-9]{2}-[0-9]{2}-[0-9]{4}
If you still feel deprived, you could use Perl instead, whose regular expressions have all kinds of wacky features (not that you need most of them here):
perl -ne 'print if /\d{2}-\d{2}-\d{4}/'
--Chris Nebel
AppleScript Engineering _______________________________________________
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
_______________________________________________
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