title: R Grep file name for a variable
body: <p>I am new to R so I am struggling with what I imagine is a fairly simple question. For this question I am not looking for someone to give me just a solution. I was hoping that someone could explain the answer to me, so that I might learn to do it myself, rather than just copy what it is you have done. That being said, here is my problem and questions.</p>
  
  <p>I am making a histogram with R. A user will submit a file and data from that file will be used to make a histogram. That much is already set and done. Where I am having a problem is that I need to take only part of that file name and use it to help make a title for the histogram. The file name is a bit of a monster and follows this naming convention: </p>
  
  <blockquote>
    <p>X_Y.doc.Z.x_y_z </p>
  </blockquote>
  
  <p>The aspects of that file name that I need are the Y and Z. I know that many people use grep but I am not sure how to use it in this instance. I have already read the ??grep page and am familiar with the basics of grep but don't really know where to start. </p>
  
  <p>Eventually I will also need to grep some information from an excel file, if someone cares to advise me in that matter as well.
  If it helps, this is how I am accepting the files: </p>
  
  <pre><code>F.n&lt;-(tk_choose.files(default="", caption="Select a file", multi=TRUE, filters=NULL, index=1))
  </code></pre>
  
  <p>Does anyone have any suggestions? </p>