Parsing Author Names to BibTeX Format

A simple macro to find and replace text is perfectly working if I used on the System Clipboard; but fails if use it on a variable or NamedClipboard.

11_10_21 at 05.19.57PM

From SystemClipboard: haspelmath, martin
From NamedClipboard: martin haspelmath

What went wrong here?

(I m using KM 9.2, if that matters).

Try (.+)\s+(.+) instead.

dear @mrpasini , thank you for the reply.
My problem is not with the regex per se (I put the above rule as a toy example). Changing the regex rule won't solve my problem because the issue on the variable search in general.

Why is the search not working on the variables while it perfectly works on the system clipboard?

Hey @Desalegn,

Please always post an actual macro demonstrating your issue.

Not doing so puts too much burden upon those who might want to help and makes them guess about conditions that would be solidly provided by a proper test-case.

Guessing often wastes everyone's time.

Your image above shows the SYSTEM-Clipboard rather than a variable or a NAMED-Clipboard, so we can't tell what you're actually doing.

My test-case in Keyboard Maestro 10 shows search/replace working equally well in a variable and a named clipboard. (I also tested the system clipboard separately for good measure.)

Your regular expression doesn't need a linefeed character, as the EOL ($) will always precede it.

Your regex is better written something like this:


Although I'd probably write it like this:


Take Care,
Christopher Stone

(Keyboard Maestro Moderator)

Search & Replace Clipboard vs Variable v1.00.kmmacros (9.6 KB)


Keyboard Maestro Export

1 Like

Dear @ccstone
Thank you for the reply. You are right, putting a hypothetical case is wrong on my side.

Actually, I am trying to parse Authors to appear in the correct Bibtex format.

I have a list of authors as follows (for 3 or more authors)

Martin Haspelmath, John A. Smith, and Armad Mary

and two authors such as

Martin Haspelmath and John A. Smith

and single author:

Martin Haspelmath

I want to turn them to proper Bibtex format like the following (for the 3 authors):

Haspelmath, Martin
Smith, John A.
Mary, Armad

The regex you gave me is correctly working. I am getting good results now.

Oh, thank you for the help guys. It is working now.

I am posting it here, and changing the title of the post if sb find the macro helpful.

(I would also be interested if sb come up with a better way of doing it)

parseAuthors.kmmacros (11.5 KB)

Here's my take.


Parsing Authors to Bibtex format v1.00.kmmacros (11 KB)
Keyboard Maestro Export

1 Like

Thank you.

1 Like