title: How to Extract a substring from a flowfile Name in NIFI
body: <p>I have a file called 'test.abcde.houses.csv' and I want to extract the substring 'abcde' which I will use in my next processor group to query the database.</p>
  <p>Currently, I am using the updateAttribute Processor group to try to extract the substring.</p>
  <p><a href="https://i.stack.imgur.com/sVo6D.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/sVo6D.png" alt="UpdateAttribute" /></a></p>
  <p>This is the code I am using in the value section.</p>
  <pre><code>var userPattern = java.util.regex.Pattern.compile('(.+?)\.[0-9]{8}-[0-9]{7,9}\..+');
  var userMatcher = userPattern.matcher(fileName);
  var matchExists = userMatcher.matches();
  
  
  
  var user;
  var userRemove;
  
  
  
  if (matchExists) {
  user = userMatcher.group(1);
  userRemove = user + &quot;.&quot;;
  }
  else {
  throw 'Unable to parse username from file metadata.';
  }
  </code></pre>
  <p>Question:</p>
  <ol>
  <li>Is this the right way to extract a substring from a flow file name in NIFI?</li>
  <li>Am I using the right processor group?</li>
  <li>Does this code work with Nifi?</li>
  </ol>