Re: QuarkXpress find and replace with variables (new question)
Re: QuarkXpress find and replace with variables (new question)
- Subject: Re: QuarkXpress find and replace with variables (new question)
- From: Hans Haesler <email@hidden>
- Date: Sun, 28 Jan 2001 14:00:51 +0100
On Sat, 27 Jan 2001, Arthur J Knapp wrote:
>
[snip]... Good stuff
Thanks. :-)
>
Just take advantage of the RegEx patterns:
>
REReplace storyOne with "uno" pattern "\\<(one)\\>" ignoreCase (false)
Yes, that does the trick. And it is much better than typing spaces before
and after the words, e.g. " one ", a method which fails when there are
punctuation characters or parentheses or the like.
Two remarks:
1) You don't need to add 'ignoreCase (false)'. That's the default.
2) The search and replace strings should be set up with variables since
there are several items in the lists:
---
set storyOne to (REReplace storyOne pattern "\\<" & item1 & "\\>" with item2)
---
(... and I prefer to put the replace string at the end of the line.)
As an exercise :-) I tried to _exclude_ the case when "one" is part of
composed words as in "one-man show":
---
set storyOne to
(REReplace storyOne pattern "\\<" & item1 & "\\>([^-])" with item2 & "\\1")
---
When the "^" character is the first in the brackets then this will
match anything except the following character(s). So, '([^-])' matches
any character except "-". The parentheses designate group 1 which is
backreferenced by "\\1". And that's another reason for ending the line
with the replace string. The command is easier to read.
Regards,
Hans
---
Hans Haesler | email@hidden