• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Regex on OS X
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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.

References: 
 >Re: Regex on OS X (From: bill fancher <email@hidden>)

  • Prev by Date: Re: Regex on OS X
  • Next by Date: 'System Events.app' won't get processes in Classic under 10.2
  • Previous by thread: Re: Regex on OS X
  • Next by thread: Re: Regex on OS X
  • Index(es):
    • Date
    • Thread