 <p>Try this regular expression:</p> <pre><code>CONSTRAINT \[PK__onepk__([\w^\]]+)\] PRIMARY KEY CLUSTERED </code></pre> <p>Given this input string:</p> <pre><code>CONSTRAINT [PK__onepk__321403CF014925CB] PRIMARY KEY CLUSTERED </code></pre> <p>This part of the expression</p> <pre><code>([\w^\]]+) </code></pre> <p>Will match </p> <pre><code>321403CF014925CB </code></pre>