title: Regex to recognise repeating characters
body: <p>I am trying to use regex to locate pairs of BELL characters in a string. </p>
  
  <p>My problem is that with my current solution I will - if I have 6 Bell chars after another find a match between 1 and 2, 3 and 4, 5 and 6 but I also need to find that 2 and 3 are a pair and 4 and 5. I have made a picture of how it looks like from regex.com that will probably make it very apparent what my challenge is.</p>
  
  <p>I realize that I could split the string for every Bell and loop through the result and check for every empty instance but since I will be processing rather large files I assume that regex could be more efficient.</p>
  
  <p><a href="https://i.stack.imgur.com/FQ4yY.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/FQ4yY.jpg" alt="picture from regex showing match in current code"></a></p>
  
  <p>The purpose is to be able to replace empty values with something else. I cannot write BELL in this form field but in the below example i am using <code>.</code> to represent BELL. Input could be <code>.0......2.</code> and I would like to make that <code>.0.999.999.999.999.999.2.</code> but currently I am getting <code>0..999..999..999.2.</code>.</p>
  
  <p>The code is like this: </p>
  
  <pre><code>var lines = File.ReadAllLines(dir + "Temp5\\" + filname + ".csv"); 
  using (var sw = new StreamWriter(dir + "Final\\" + filname + ".csv")) 
  {
      foreach (string line in lines) 
      {
          cleanline = Regex.Replace(line, @"", "999");
          sw.WriteLine(line2); 
      }
  }
  </code></pre>