title: RegEx -- Quantifier {x,y} following nothing error
body: <p>I am very new to RegEx -- so can someone please help me figure out what exactly is going wrong here?</p>
  
  <p>I have this code:</p>
  
  <pre><code>       string regPattern = "*[~#%&amp;*{}/&lt;&gt;?|\"-]+*";
         string replacement = "";
         Regex regExPattern = new Regex(regPattern);
  </code></pre>
  
  <p>Yet, when my app hits the regExPattern line, i get an ArgumentException -- Quantifier {x,y} following nothing error.</p>
  
  <p>Can someone help?  </p>
  
  <p>EDIT:  I need to pass this pattern into a foreach loop like so:</p>
  
  <pre><code>    if (paths.Contains(regPattern))
          {
              foreach (string files2 in paths)
              {
                  try
                  {
                      string filenameOnly = Path.GetFileName(files2);
                      string pathOnly = Path.GetDirectoryName(files2);
                      string sanitizedFileName = regExPattern.Replace(filenameOnly, replacement);
                      string sanitized = Path.Combine(pathOnly, sanitizedFileName);
                      //write to streamwriter
                      System.IO.File.Move(files2, sanitized);
  
                  }
                  catch (Exception ex)
                  {
                      //write to streamwriter
  
                  }
              }
          } 
          else
          { 
          //write to streamwriter
  
          }
  </code></pre>
  
  <p>How do i define the pattern if it is being passed into this loop?</p>