title: How to Match on single digit values in a CSV String
body: <p>I am simply needing to locate single digits of Seven, Eight or Nine that exist as a value in a CSV string.  This string can also contain nothing or a single value, and so no commas if it is just a single value.  I need to discover a RegEx Pattern that can match on just 7 or an 8 or a single 9.  NOT 77... not 88 not 78 not 17 and not 97.  Each match is looking for single value entries between each comma.</p>
  <p>Currently, I have a Regular Expression that correctly locates the matches in between commas.  However, it is failing to find those same matches when the value being searched is at the Beginning or the End of the string.  Each time I try adding syntax to my RegEx to get it to find single 7s, 8s or 9s at the beginning or end, it then also starts finding non-valid entries within the String between commas such as 77 or 9Trunnion.</p>
  <p><code>My Sample String: '7,8,9'.</code></p>
  <p><code>My Pattern: (?&lt;=,)[789](?=,)</code></p>
  <p>Another Sample String: <code>'15,7,98,0,null,Bad Data,9s,7,4,8'</code></p>
  <p>Link to Demo: <a href="https://regex101.com/r/8fAJEN/1" rel="nofollow noreferrer">https://regex101.com/r/8fAJEN/1</a></p>
  <p>Screenshot:
  <a href="https://i.stack.imgur.com/h1ZYj.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/h1ZYj.png" alt="enter image description here" /></a></p>
  <p>This question was marked as having a <a href="https://stackoverflow.com/questions/19512586/regex-to-match-text-between-commas">duplicate</a> however I already reviewed this SO Post prior to creating this question as I could not figure out how to match on just single digit values within the CSV.  My question takes the issue further by asking the question on how next to match on the strings between the commas.  The SO Post marked as a duplicate to THIS question again is NOT a duplicate.  It doesn't go any further on showing how to then match on the string between the commas.  It does correctly show how to match WHOLE STRINGs between commas but that is it.  Begin novice at RegEx I needed more assistance in matching on the Strings within the commas and I could not figure out how.</p>
  <p>Pattern in the NOT !Duplicate Post:</p>
  <pre><code>(?&lt;![^,])[^,]*(?![^,])
  </code></pre>
  <p>I've pasted below the Two Patterns provided as solutions to THIS SO Post and they are:</p>
  <pre><code>(?&lt;=^|,)[789](?=,|$) Provided by @Bohemian and chosen as the Correct Answer
  
  (?:(?&lt;=^)|(?&lt;=,))[789](?:(?=,)|(?=$)) Provided in comments by @Ouroborus
  </code></pre>