Help with Regex in key generation

I am trying to figure out how to set up citation key generation and file matching to match my own, long entrenched personal methods.

When citing papers I pretty much use either

  1. AuthorYear
  2. Author1AndAuthor2
  3. Author1EtAl

Using the key [auth.etal][year]
with the regex replacement
\.(?!etal) -> And
I can get JabRef to do

  1. AuthorYear
  2. Author1AndAuthor2
  3. Author1.etal

but I can’t figure out how to get the third case to work.

I see two possible paths to a solution, but both are beyond my understanding.

  1. Some how modify my regex set up to allow for a more complex substitution (i.e., replace ‘.etal’ with ‘EtAl’ and every other ‘.’ with an ‘And’). I don’t understand how I can do this since my regex skills are very limited.

  2. Utilize the undocumented ability to use regex within a key term. Unfortunately, looking at the code is unclear how to do this. I know the syntax is something like `[auth.etal:regex.XXXX]’, but beyond that I’m lost.

Could someone help me out?

Thanks,

Mike

I’m not sure I understand your question, but wouldn’t [authEtAl][year] do what you need for the third case?

[auth.etal:regex("\\.etal","EtAl")] is the syntax for the regex modifier. I am also not completely sure of what you need, could you give some examples?

Yes, but it doesn’t allow me to insert the ‘And’ between the two author names when I am dealing with only two authors.

Ahhh this is what I was looking for!

I believe I want to use [auth.etal:regex("\\.etal","EtAl"):regex("\\.","And)] to get the desired pattern.

Much obliged. I will try to add some documentation for other clueless folks like me.

Now on to pdf file names!

2 Likes

@mikegilchrist
It would be really nice if you could improve documentation here regarding the regex modifier: https://docs.jabref.org/setup/bibtexkeypatterns
(Just click on "Edit this page at Github in the top right corner)

Awesome ! That is always needed and appreciated :stuck_out_tongue:
If you feel comfortable with adding the documentation it is part of issue #179