What is a regex to match ONLY an empty string? February 21, 2023 by Tarik It’s as simple as the following. Many of the other answers aren’t understood by the RE2 dialect used by C and golang. ^$