Search code examples
regexapache-nifiupdate-attributes

Using Apache NiFi how can I remove the last character in the flowfile content or Attribute's Value


I'm trying to figure out how to remove the final , in a flowfile's attribute named "LIST" The value of the attribute is below:

LIST

(65860064,17109,17216),(67705819,312226,17216),(69601952,17109,17216),(70767264,584282,17232),(62292705,242958,17305),(68902821,17842,17357),(63676040,583969,17419),(62177246,583146,17421),(61940106,286268,17582),(63076031,314386,17591),

The FlowFile content is the same as the LIST so that could also be manipulated in order to solve this problem.

Any help would be greatly appreciated. I thought using an updateattribute processor would work, but I can't figure out an equivalent of len("LIST",-1)


Solution

  • In NiFi Expression Language (in UpdateAttribute for example), you can use substringBeforeLast(',('), that should return all the elements in the list except the last one.