Match both of these with regex, not just one of
<p>I'm looking in a sql table through a bunch of names and I want to get a list of all the different titles used. e.g. SNR, MRS, MR, JNR etc</p>

<p>Sometimes there is an entry that might have 2 titles, e.g:  MR NAME NAME JNR. I want both of these titles 'MR' &amp; 'JNR'</p>

<p>I thought a good way to do this would be with regex and find any names that have 2 or 3 characters. A title at the front would be followed by a space, while a title at the end would be preceded by one. So I have:</p>

<pre><code>/(^[A-Z]{2,3})\s|\s(^[A-Z]{2,3}$)/
</code></pre>

<p><a href="https://regex101.com/r/iQ2dB6/2" rel="nofollow">a regex101 example here</a>.</p>

<p>As you can see I've used 'match either A or B' thing. If I throw at it a name with a title at either the start or finish, I end up getting what I want, but I don't know how to tell it to get both. i.e. strings with 2 titles will only give me back one match.</p>

<p>How do I get both?</p>