styling references using wildcards/find-replace

H

hendrik

I am trying to style references with macros/wildcards, using the
find/replace function, like
140 Vogler BK, Pittler MH, Ernst E. Feverfew as a preventive treatment
for migraine: a systematic review. -Cephalagia- 1998; *18:* 704–08.
I managed to bold the volume numbers, since nowhere else in references
there are digits followed by a colon. However, I don't know how to
specify the place where the publications sit: they are followed by the
publication date, and the semi-colon, but the space before is not
specific enough (there are many other occurrences of a full stop
followed by a space), so that any find/replace function I created
selected more text than I wanted.
Any solutions?
 
K

Klaus Linke

Hi Hendrik,

Not sure, but perhaps the following three "expressions" might be specific
enough for publications:
-- Full stop and space before;
-- Starts with one or more words, and ends with a four-digit number;
-- Semicolon after.

You could put in <pub>tags</pub> in a first step:
Find what: (. )([A-Za-z\- ]@[0-9]{4})(;)
Replace with: \1<pub>\2</pub>\3

In a second step, you could format the stuff between <pub> and </pub> in a
certain way:
Find what: \<pub\>(*)\</pub\>
Replace with: \1 ((using some character style or formatting))

(The tags are automatically deleted as you replace with \1, the stuff in
the -- first and only -- bracketed pattern)

You'll probably have to add a couple of characters to [A-Za-z\- ] as you go
along ("&", "/", ...).
And even then, you may miss some special cases, or get wrong matches.

To avoid wrong matches (as in "This novel was written 1954; it first
appeared in ..."), you could for example try to limit the length of the
publisher's name to a max of 20 characters or so:
Find what: (. )([A-Za-z\- ]{1;20}[0-9]{4})(;)

Greetings,
Klaus
 
K

Klaus Linke

I am trying to style references with macros/wildcards, using the
Probably misunderstood your requirements a bit.

As you surely already figured out, you can find the puiblisher without the
year by moving [0-9]{4} into the third group.
Find what: (. )([A-Za-z\- ]@)([0-9]{4};)

I use the same general technique in lots of situations:
-- Put the stuff preceeding the things you want to find in a first (group)
-- Put the things you are interested in into a second (group).
-- Put the things that follow into a third (group).
-- Put in tags \1<tag>\2</tag>\3

Sometimes you only need the preceeding or only the following (group).
Anyway, you have much more control over what is matched than if you try to
only match the stuff that you are really interested in.
It's then rather easy to process the tagged text with a further replacement.

Klaus
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top