title: c++ Regex for reading Complex Numbers
body: <p>I'm trying to write a regular expression to match the input of complex number in the following forms:
  (With a,b real number, and i/I imaginay unit)</p>
  
  <p>a</p>
  
  <p>a+bi</p>
  
  <p>a-bi</p>
  
  <p>+bi</p>
  
  <p>-bi</p>
  
  <p>a+i</p>
  
  <p>a-i</p>
  
  <p>i</p>
  
  <p>-i</p>
  
  <p>Of course in all numbers I want to be able to also read exponential form (eg: 1.23e+45-67.89e-1256i).
  I've come up with this:</p>
  
  <pre><code>   regex aplusbi ("(([\\+-]?[\\d]+([\\.][\\d]+)?)?([eE][\\+-]?[\\d]+)?)?(([\\+-])?(([\\d]+?([\\.][\\d]+)?)?([eE]?[\\+-]?[\\d]+)?)?[iI])?")
  </code></pre>
  
  <p>It gets most of them correct, however when I input +bi or -bi or simply bi the b part goes into the real one, and it also recognises this number as correct:</p>
  
  <p>12.418.546i</p>
  
  <p>getting 12.41 into the real part and 8.546 into the imaginary one. How could I correct it? I'm kind of new to C++ and regexes so any kind of help would be appreciated, thanks!</p>