Re: Regex on OS X
Re: Regex on OS X
- Subject: Re: Regex on OS X
- From: John Delacour <email@hidden>
- Date: Wed, 2 Oct 2002 11:25:56 +0100
At 4:23 pm -0700 1/10/02, bill fancher wrote:
My script does what you *claimed* your script does: "print all lines
that contain 'Jan'". Is it my problem that your script isn't up to
spec? (I did run it, just didn't notice that it didn't do what it
was supposed to.)
I notice you have not actually supplied the UNIX shell script that
_does_ print all the lines whose name is 'Jan' and not 'Jan*' without
the preceding number and space. I look forward to seeing this.
The point is that grep is one limited implementation of regular
expressions and people often confuse "grep" and "regex"
At 10:17 pm -0400 1/10/02, Ken Fleisher wrote:
.. I think this solution of passing it on to grep is a great one and
that's the route I'll take. Now I just have to learn how to do that!
Is there someplace I can go for reference on grep (if it's the same
syntax as in BBEdit, then I can use that manual for reference)?
The syntax is not the same as in BBEdit and not the same as in Nisus
etc. etc. and I would recommend taking the UNIX/perl syntax as the
standard and considering other implementations as variations -- which
are quite easy to adapt to.
For a very complete treatment of regular expressions, I'd recommend
reading first perlretut.pod and then perlre.pod. You can get these
as html files using the following script. When you want to learn
more about perl, you can choose other pods. Perl is a language that
actually has proper documentation.
set browser to "Omniweb" -- the name of your browser
set pods to "" & (path to startup disk) & "Library:Perl:Pods:"
set ls to list folder pods
set ppt to "Choose a pod"
choose from list ls with prompt ppt default items "perlretut.pod"
set choice to result as string
set AppleScript's text item delimiters to {"."}
set pod to first text item of choice
set AppleScript's text item delimiters to {""}
do shell script "pod2html /Library/Perl/pods/" & pod & ".pod"
set htmlText to result as string
set tmp to (path to temporary items) as string
set f to tmp & pod & ".html"
try
close access file f
end try
open for access file f with write permission
set eof file f to 0
write htmlText to file f
close access file f
tell application browser
open {alias f}
activate
end tell
I think you'll find this a rather astonishing piece of magic. Save
the script in ~/Library/Scripts/ as "pod2html" and you will have
ready access to all the perl pods.
There is a neater and shorter way to do this, but it eludes me at the moment
pod, incidentally, stands for plain old documentation.
I view discouraging the spread of perl as a civic duty. It's like kudzu.
If things don't change soon , I'll have a similar mission with regard
to AppleScript :-)
JD
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.