• 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: Find duplicate numbers and replace
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Find duplicate numbers and replace


  • Subject: Re: Find duplicate numbers and replace
  • From: "Mark J. Reed" <email@hidden>
  • Date: Wed, 14 May 2008 12:50:42 -0400

On Wed, May 14, 2008 at 12:27 PM, Script2 <email@hidden> wrote:
> I want to write a script that will find the second, third……occurrence of
> number (the number is always before [F]) and add "a" to second occurrence,
> "b" to third occurrence so on. Appreciate any suggestions or script
> examples. OS 10.3

This is a good candidate for Perl...

do shell script ("perl -i.bak -e 'undef $/; $_ = <>; while
(/(\\d+)\\[F\\]/g) {  my $n = $1; my $a = \"a\"; substr($_, pos($_))
=~ s/$n\\[F\\]/$n . $a++ .\"[F]\"/ge;} print;' " & POSIX path of
myTextFile)

As written it modifies the text file in place, after making a backup
copy named by appending ".bak" to the original filename.

--
Mark J. Reed <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:
Archives: http://lists.apple.com/archives/applescript-users

This email sent to email@hidden

  • Follow-Ups:
    • Re: Find duplicate numbers and replace
      • From: "Mark J. Reed" <email@hidden>
References: 
 >Re: Re1: Mail scripting : How to select… continuation... (From: Philip Aker <email@hidden>)
 >Find duplicate numbers and replace (From: "Script2" <email@hidden>)

  • Prev by Date: Find duplicate numbers and replace
  • Next by Date: Re: Find duplicate numbers and replace
  • Previous by thread: Find duplicate numbers and replace
  • Next by thread: Re: Find duplicate numbers and replace
  • Index(es):
    • Date
    • Thread