title: Regex for Uppercase Letters, Numbers and dashes only
body: <p>I have struggled with this expression for 2 days now so I thought I'd ask for some proper help from the world of knowledge. I hope someone can help.</p>
  
  <p>This is the RegEx I built to get me what I want.</p>
  
  <pre><code>\S*\d*?-[A-Z]*[0-9]*
  </code></pre>
  
  <p>I only want the Uppercase Letters and Numbers with dashes, so it does get <code>GC-113</code>, <code>AO-1-GC-113</code>, <code>AO-2-GC-113</code>, which is great!</p>
  
  <p>"I don't want this <code>------</code>, but this is good <code>GC-113</code>, <code>AO-1-GC-113</code>, <code>AO-2-GC-113</code>"</p>
  
  <p>BUT if I come across one where there is no space between the number, but just another character like a comma or a period then it returns a match on the entire section "<code>GC-113,AO-1-GC-113,AO-2-GC-113</code>"</p>
  
  <p>"I don't want this <code>------</code>, but this is good <code>GC-113,AO-1-GC-113,AO-2-GC-113</code>"</p>
  
  <p>I'm using RegExBuddy to try and figure this out.</p>
  
  <p>This is the VBA code I'm using get the matches.</p>
  
  <pre><code>Public Function GetRIs(ByVal vstrInString As String) As Collection
  Dim myRegExp As RegExp
  Dim myMatches As Variant
  Dim myMatch As Variant
  
  Set GetRIs = New Collection
  Set myRegExp = New RegExp
  
  myRegExp.Global = True
  myRegExp.Pattern = "\S*\d*?-[A-Z]*[0-9]*"
  Set myMatches = myRegExp.Execute(vstrInString)
  
  For Each myMatch In myMatches
      If myMatch.Value &lt;&gt; "" Then
          GetRIs.Add myMatch.Value
      End If
  Next
  
  End Function
  </code></pre>
  
  <p>Thanks!
  Dave</p>