# Help with Regex in key generation

**URL:** <https://discourse.jabref.org/t/help-with-regex-in-key-generation/2115>\
**Category:** Help\
**Created:** [May 21, 2020, 8:11pm UTC](https://discourse.jabref.org/t/help-with-regex-in-key-generation/2115 "2020-05-21T20:11:19Z")\
**Posts on this page:** 1\
**Showing post:** 1

<div class="post-metadata">

**Author:** ![mikegilchrist](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.jabref.org/mikegilchrist/32/697_2.png) [@mikegilchrist](https://discourse.jabref.org/u/mikegilchrist)\
**Post date:** [May 21, 2020, 8:11pm UTC](https://discourse.jabref.org/t/help-with-regex-in-key-generation/2115/1 "2020-05-21T20:11:19Z")

</div>

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](https://github.com/JabRef/jabref/blob/7895ae07443612c63fee950ddee88650fecb4d91/src/main/java/org/jabref/logic/formatter/Formatters.java#L68-85) 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

---

_[View the full topic](https://discourse.jabref.org/t/help-with-regex-in-key-generation/2115)._
