• 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: Regular Expressions and Smile
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Regular Expressions and Smile


  • Subject: Re: Regular Expressions and Smile
  • From: "J.B. Stewart" <email@hidden>
  • Date: Thu, 10 Jan 2002 20:35:27 -0500

On 1/10/02 at 5:39 PM, Daniel A. Shockley <email@hidden> wrote:

> Any ideas?
>
> Here's some sample code:
> ------------------
> set myText to "John Smith
> Jeff Matthewson
> Robert Downing
> JOHN Stephenson"
>
> set newText to REReplace myText pattern "^John (.+)" with "\\1, John"
> ignoreCase true
> -------------
> When you compile and run this, you get what you want. The script compiles to:
> ------
> set myText to "John Smith
> Jeff Matthewson
> Robert Downing
> JOHN Stephenson"
>
> set newText to REReplace myText pattern "^John (.+)" with "\\1,
> John" with ignoreCase
> -------
> and works, returning:
> "Smith, John
> Jeff Matthewson
> Robert Downing
> Stephenson, John"
>
> If you leave out the ignoreCase, it won't change the JOHN Stephenson
> line. Granted in this example you can add extra code to first
> correctly capitalize the name, but that is just not possible for all
> the places I've used BBEdit already.
>
> However, now that the script has TWO 'with' commands, it will fail on
> Syntax checking. This is bad, and I don't know of any way to keep
> AppleScript from changing the form. Does anyone else?
>
> Short of that, does anyone know a better or alternate way of doing
> multiple fast greps in Mac OS 9 AppleScript? (I know I could use
> other tools in Mac OS X, or even MacPerl)

You're gonna love this one, at least it works OMM using AS 1.7 OS 9.2.2 in
Script Debugger 3.0.1

John

set myText to "John Smith
Jeff Matthewson
Robert Downing
JOHN Stephenson"

-- following is all on one line
set newText to REReplace myText pattern "^John (.+)" with "\\1, John" ignoreCase
1 -- is "one" not "L"


References: 
 >Regular Expressions and Smile (From: "Daniel A. Shockley" <email@hidden>)

  • Prev by Date: Re: Problems with Smile 1.8.4 and system 9.2.2
  • Next by Date: RE: Problems with Smile 1.8.4 and system 9.2.2
  • Previous by thread: Regular Expressions and Smile
  • Next by thread: Re: Regular Expressions and Smile
  • Index(es):
    • Date
    • Thread