OK, now that we have a more complete set of example references (source data), and the details of your requirements, we can offer a better solution.
Given these 3 examples:
(which I have modified slightly to test for better matching)
Amiot, D. (2004). Haut degré et préfixation. In F. Lefeuvre & M. Noailly (Eds.), Travaux linguistiques du Cerlico: Vol. 17. Intensité, Comparaison, Degré (pp. 91–104). Rennes: Presses Universitaires de Rennes.
Amiot, D. X. Haut degré et préfixation. In F. Lefeuvre & M. Noailly (Eds.), Travaux linguistiques du Cerlico: Vol. 17. Intensité, Comparaison, Degré (pp. 91–104), (2005). Rennes: Presses Universitaires de Rennes.
Amiot, David X. Haut degré et préfixation. In Travaux linguistiques du Cerlico: Vol. 17. Intensité, Comparaison, Degré (pp. 91–104), (2005), F. Lefeuvre & M. Noailly (Eds.),. Rennes: Presses Universitaires de Rennes.
I have written a macro that produces this result (as an example):
RegEx to Extract Author, Year, & Title
Note the following, and confirm that it meets your requirements, and the variations in reference formats that you need to deal with:
- Author
- This will handle a variety of author names, as well as being followed by either the Year, or other text, as shown here:
.
- Year
- RegEx:
\(([12]\d{3})\)
- For details see regex101: build, test, and debug regex
- Supports matching the Year in the following pattern:
- 4 digits, that start with 1 or 2, in parenthesis.
. (match highlighted in green)
- Note that the last example, "(3004)" did NOT match.
.
- Title
<Prefix><Title><Suffix>
where:
• <Prefix> is ". In "
• <Title> is the Title to be extracted, which must end with a page reference like "(pp. 91-104)"
• <Suffix> is a space, comma, or period.
OK, so here's the macro. Please review & test and let us know if it works for you.
MACRO: Extract Author, Year, & Title from Reference [Example] @RegEx
#### DOWNLOAD:
<a class="attachment" href="/uploads/default/original/3X/f/c/fcaadffd06b1608f5984c8d5425da5674c78476b.kmmacros">Extract Author- Year- & Title from Reference [Example] @RegEx.kmmacros</a> (110 KB)
**Note: This Macro was uploaded in a DISABLED state. You must enable before it can be triggered.**
---
### ReleaseNotes
Author.@JMichaelTX
**PURPOSE:**
* **Extract the Author, Year, and Title from standard references**
* It is designed to handle different formats
**HOW TO USE:**
1. Copy reference string (one line) to Clipboard
2. Trigger this macro
**NOTICE: This macro/script is just an _Example_**
* It is provided only for _educational purposes_, and may not be suitable for any specific purpose.
* It has had very limited testing.
* You need to test further before using in a production environment.
* It does not have extensive error checking/handling.
* It may not be complete. It is provided as an example to show you one approach to solving a problem.
**REQUIRES:**
1. **KM 8.2+**
* But it can be written in KM 7.3.1+
* It is KM8 specific just because some of the Actions have changed to make things simpler, but equivalent Actions are available in KM 7.3.1.
.
2. **macOS 10.11.6 (El Capitan)**
* KM 8 Requires Yosemite or later, so this macro will probably run on Yosemite, but I make no guarantees. :wink:
**MACRO SETUP**
* **Carefully review the Release Notes and the Macro Actions**
* Make sure you understand what the Macro will do.
* You are responsible for running the Macro, not me. 😉
.
* Assign a Trigger to this maro.
* Move this macro to a Macro Group that is only Active when you need this Macro.
* ENABLE this Macro.
.
* **REVIEW/CHANGE THE FOLLOWING MACRO ACTIONS:**
* ALL Actions that are shown in the magenta color
**USE AT YOUR OWN RISK**
* While I have given this limited testing, and to the best of my knowledge it will do no harm, I cannot guarantee it.
* If you have any doubts or questions:
* **Ask first**
* Turn on the KM Debugger from the KM Status Menu, and step through the macro, making sure you understand what it is doing with each Action.
---
![image|473x2000](upload://qkcWI8OzXQmT2f6BG5tOy7U2tRj.png)