Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save saravanabalagi/5490275c39e5e888227a46ec36531dc0 to your computer and use it in GitHub Desktop.
Save saravanabalagi/5490275c39e5e888227a46ec36531dc0 to your computer and use it in GitHub Desktop.
Regex to find consecutive \cite commands
  1. Avoid multiple consecutive \cite commands in succession, e.g. \cite{my_citation_1}\cite{my_citation_2}
  2. Combine into a \cite{} with citations separated by comma, e.g. \cite{my_citation_1,my_citation_2}

Regex

Use the following regex to find such patterns

\\cite\{([\w,]+)\}([ ~,;]*\\cite\{([\w,]+)\})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment