Can you guys help me to capture the Last Name of the First Author.
Here are the name patterns:
- Carol Padden, Irit Meir, So-One Hwang, Ryan Lepic and Sharon Seegers,
- John B. Haviland
- D.N. B. Dixon
What I want is to capture "Padden" from the first, "Haviland" from the second and "Dixon" from the third.
Can you clarify more?
Where do you have the source string for process? Read it from a file to variable? Copy it to the clipboard?
Also, how do you want the result to be formatted? Capture the one last name at a time and do something, then the 2nd last time, or capture them all together, separated with
I already put the names of the authors to the variables.
I want to capture the Last name of the first Author from the Author Variable.
I have tried
But, it is not matching correctly.
Your screenshot shows that there is yet another pattern:
Oksana Thachman And Wendy Sandler, which makes the regex a bit more complex.
Are you sure these are all the patterns?
It looks like you only need to capture one last name at a time, right?
Oh, yes, that is another pattern. But, I was thinking it would be the same pattern to the first one: Carol Padden because the first author is set as "FirstName LastName".
The focus is only on the first author.
I am hopping that the macro will be able to capture exactly the last name of the first author every time I run it.
To clarify the background, I am trying to scrap references from Table of contents of Edited books. The names come in different patterns. I want to put the LastName of the First author as my CitationKey. that is why I want to get that one only.
In the screenshot, I was trying to capture "Tkachman". But, I am getting "Sandler".
They are different to computer. In the first case, the last name is followed by a comma
In your screenshot, it is followed by
░And (there is a space before `And.
Try this macro below. It works with all the patterns you've posted. If there is yet another pattern, let us know.
RegEx.kmmacros (1.7 KB)
This has worked beautifully. Thank you so much dear @martin