Skip to content

Instantly share code, notes, and snippets.

@grahamperrin
Last active December 18, 2022 18:45
Show Gist options
  • Save grahamperrin/7b898d5d035a9470b2314b371c09119d to your computer and use it in GitHub Desktop.
Save grahamperrin/7b898d5d035a9470b2314b371c09119d to your computer and use it in GitHub Desktop.
Extended Regular Expression (ERE) trial and error

Extended Regular Expression (ERE) trial and error

Rough notes following help from a human in #devguide in Discord for FreeBSD, https://discord.com/channels/727023752348434432/783418678279929896

Examples

Git commits to the FreeBSD ports tree may have an unpredictable number of spaces in the approval line

https://cgit.freebsd.org/ports/commit/?id=fc8a32e96a7a72096ed30d4abf0a0aa7b425c1c5 (2022-12-10)

Approved by:            dbaio@
  • twelve spaces after the colon

https://cgit.freebsd.org/ports/commit/?id=02de50dcbd9aec2fcf1c0f4a4fd0fe6e25085458 (2021-04-18)

Approved by: dbaio@
  • one space

git -C /usr/ports log --extended-regexp --grep='Approved by: {1,}dbaio'

  • finds those two.

Git commits to the FreeBSD ports tree may have an unpredictable number of horizontal tabs in the approval line

https://cgit.freebsd.org/ports/commit/?id=b4fc2a71b177f4a1d9824eb246f25140d929a34f (2022-03-14)

Approved by:		ports-secteam (zeising)
  • two tabs after the colon

git -C /usr/ports log --no-expand-tabs --extended-regexp --grep='Approved by:[[:cntrl:] ]{1,}ports'

  • finds that commit, amongst many others that were approved by ports or ports⋯something-or-other

git -C /usr/ports log --no-expand-tabs --extended-regexp --grep='Approved by:[[:cntrl:] ]{1,}port'

  • broader, includes approvals by portmaster@⋯, portmgr, portmgr@, and so on.

Background

Committer's Guide: metadata: group and team names by grahamperrin · Pull Request #104 · freebsd/freebsd-doc

Team names should be discoverable. …

Credit

To Dan Nelson for being extraordinarily helpful, and patient, in Discord.

References

grep(1) https://www.freebsd.org/cgi/man.cgi?query=grep&sektion=1&manpath=FreeBSD

Regular expression - Wikipedia https://en.wikipedia.org/wiki/Regular_expression

Regular Expressions https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap09.html

Regular Expressions/POSIX-Extended Regular Expressions - Wikibooks, open books for an open world https://en.wikibooks.org/wiki/Regular_Expressions/POSIX-Extended_Regular_Expressions

Git - git-log Documentation https://git-scm.com/docs/git-log

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment