In Notepad++, I would like to replace all references/citations with a citation key.
E.g., the following:
Bla bla bla bla (van Author et al., 2015).
Bla bla bla (Authorone, Authortwo, & Authorthree, 2016).
Bla bla (Authorone & Authortwo, 2017).
Should become:
Bla bla bla bla (vanAuthor2015).
Bla bla bla (Authorone2016).
Bla bla (Authorone2017).
Note that there might also be multiple references in a single line, but there are no nested parentheses.
In a first step I replaced (?<=\([a-z][a-z][a-z])\s
with nothing to turn the first citation from (van Author et al., 2015)
into (vanAuthor et al., 2015)
. This would also work for (von Author et al., 2015)
.
Explanation:
\s
Remove single white space(?<=
that follows\([a-z][a-z][a-z])
an opening parenthesis and 3 lower-case letters.)
close positive lookbehind.
However, I am struggling with the 2nd step. How can I replace the first whitespace until the last whitespace after a comma \s.*,\s
only within parentheses? I read many posts titled "regex only in brackets" but the solutions I came across did not appear to apply to my case.