Re: Regex on OS X
Re: Regex on OS X
- Subject: Re: Regex on OS X
- From: John Delacour <email@hidden>
- Date: Thu, 3 Oct 2002 20:06:38 +0100
At 8:34 am -0700 3/10/02, bill fancher wrote:
On Wednesday, October 2, 2002, at 03:25 AM, John Delacour wrote:
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.
AppleScript is quite capable of doing this unaided, but, for your
amusement and derision:
set cmd to "echo '" & s & "'|awk '/Jan[ \\t]+/ {sub(/[0-9]*[
\\t]+/,\"\");print}'"
set text item delimiters to (ASCII character 10) -- to convert CR to LF
do shell script paragraphs of cmd as text -- convert CR to LF and run script
Bwaa_bwaa_bwaa_bwaa !!
I say, I say, I say, that's SOOO much prettier and readable than
do shell script "perl -e '
$r = chr(13) ; @lines = split /$r/, qq~" & s & "~;
for(@lines) {/(\\d+\\s+)(Jan[^\\w].+)/ and print qq~$2$r~}'"
In future I'll certainly use awk for anything perl can't do. I'm
quite astonished at its grace :-)
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.