<p>I have a comma separated list of strings like the one below.</p>

<pre><code>a,b   ,c ,d, ,      , , ,e, f,g,h  .
</code></pre>

<p>I want to write a regular expression that will replace the empty values i.e., strings that contain only white spaces to 'NA'. So the result should be</p>

<pre><code>a,b   ,c ,d,NA,NA,NA,NA,e, f,g,h  .
</code></pre>

<p>I tried using ",\s+," to search but it skips the alternate empty strings and results in</p>

<pre><code>a,b   ,c ,d,NA,      ,NA, ,e, f,g,h  .
</code></pre>

<p>What's the correct regex to use here ?</p>

```
(?<=,)\s+(?=,)
```
This is a lookbehind for a comma, then whitespace, then a lookahead for a comma