• 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: replacing text - solved
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: replacing text - solved


  • Subject: Re: replacing text - solved
  • From: John Delacour <email@hidden>
  • Date: Wed, 5 Mar 2003 20:27:11 +0000
  • Mac-eudora-version: 6.0a9

At 9:13 am -0700 5/3/03, Michael Glasser wrote:

Perhaps I should have been more specific... I am having a script create a log in HTML...I want some words to be bold and underline, so I want "word" to be replaced with "<B><U>" & word & </U></B>" - at first I was doing it as a universal replace, later decided just to have it bold. With a few mods it could easily be made to replace. Anyway, here is my completed solution. changeCase does not need to be able to convert to upper or lower, but I grabbed that directly from Apple's web site and MIGHT use the other functionality of it... if not, then I will simplify it at some point.

These text things are really a case for perl, which allows you do do the most complicated replacements in a line or two and at great speed. All the bulk of the script below is overhead to get the string through the shell; the significant code is just


for ($_) {
@words = split q~ ~, q~one three~ ;
foreach $word (@words){
s~$word~<u><b>$&</b></u>~ig ;
}



set s to "one two three four five"
set f to "/tmp/junk"
set fMac to POSIX file f
try
close access fMac
end try
open for access fMac with write permission
set eof fMac to 0
write s to fMac
close access fMac
do shell script "perl -e '$f = q~" & f & "~;
open F, $f; $_ = <F> ;
for ($_) {
@words = split q~ ~, q~one three~ ;
foreach $word (@words){
s~$word~<u><b>$&</b></u>~ig ;
}
print}'"
_______________________________________________
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: replacing text - solved (From: Michael Glasser <email@hidden>)

  • Prev by Date: Re: text item delimiters question
  • Next by Date: [ANN] Philadelphia Area AppleScript User's Group Meeting
  • Previous by thread: Re: replacing text - solved
  • Next by thread: Re: Fwd: replacing text
  • Index(es):
    • Date
    • Thread