When defining a citation key pattern in JabRef it’s possible to modify a field using :regex("pattern", "replacement")
. Is it possible to use back references (e.g. \n
for whatever the nth capturing group matched) in the replacement
string?
Well … you could try. This seems highly advanced stuff you want to do.
Thanks, I have tried, naively at least, and it didn’t work. Sorry I should’ve mentioned that! I was wondering whether I needed to escape the back reference in an unusual way or use a different command.
All I want to achieve is effectively inserting a hyphen before capital letters
The only way I could think to do that is to match capital letters then replace each with a hyphen and back reference to the original matched letter
:regex("([a-z])([A-Z])","$1-$2")
In the end, this syntax works to insert a hyphen between any two consecutive letters, the first of which is lower case, and the second of which is upper case.
It seems that only $n
, and not \n
, functions correctly to return whatever the nth capturing group matched, contrary to the description linked in the JabRef documentation and quoted above. So I think the link just needs to be updated to the relevant version of Java.
@dom Thank you very much! I would appreciate it if you could add this to the documentation then as well
In the top right corner: Edit on Github