title: How to extract the strings between two special characters using Regular Expressions in C#
body: <p>I am totally new to regular expressions. And what I need to achieve is, I have a string variable containing the following string for example,</p>
  
  <p>"My Name is #P_NAME# and I am #P_AGE# years old"</p>
  
  <p>I need to extract the two strings P_NAME and P_AGE using regular expressions (to a string array or two string variables etc). i.e. the string starts with a # and ends with a # and I need to extract the middle part.</p>
  
  <p>How can I do this in C# using Regular Expressions..?</p>
  
  <p>And how can I extract the same above in case I have a new line character in between as well. i.e. for example,</p>
  
  <p>"My Name is #P_NAME# and \r\n I am #P_AGE# years old".</p>
  
  <p>Thanks</p>
  
  <p>Thanks Everyone...</p>
  
  <p>Following worked for me... I cannot publish my own answer as the answer until 8 hours expires in stackoverflow... :)</p>
  
  <pre><code>string str = "My Name is #P_NAME# and \r\n I am #P_AGE# years old";
  
  MatchCollection allMatchResults = null;
  var regexObj = new Regex(@"#\w*#");
  allMatchResults = regexObj.Matches(str);
  </code></pre>
  
  <p>'allMatchResults' contains #P_NAME# and #P_AGE# (i.e. including # character). But having it helps my other logics than not having it. </p>