Beny Spira wrote:
> Thanks Andre
> I still have a question about the script you sent. The script worked
> for words that do not precede periods or commas, but when there is a
> period or comma immediately following the word, the script does not
> recognize it and there is not italicization of the word. Is there a
> wildcard that might be added after the word?
The problem lies with the regular expression
<space>word<space>
which obviously fails if the word is followed by some punctuation.
You should have more luck with:
perl -p -e
's: word([ ,\.]):\n\\emph on\n word \n\\emph default\n\1:g'
file.lyx > file2.lyx
(All on one line).
What's changed?
<space>word<space>
becomes
<space>word([ ,\.])
([ ,\.]) is a regular expression that matches against a
single ' ', ',' or '.' and stores it in a group for later
retrieval. Note that '.' has special meaning in a regular expression,
so we indicate a literal '.' as '\.'.
It's pasted back into your reconstructed text as '\1'.
HTH,
Angus