0

Im trying to edit filename attribute with UpdateAttribute processor. I've created attribute name which is containing C:\Program Files\Filebeat\test-kafka\test_csv.csv. I would like to update filename attribute into test_csv.csv.

this is what i've done to change filename ${filename:replaceAll('.+\\', '')} and ${filename:replaceAll('.+[\\]', '')}

But the problem is, seems like it failed to escape backslash. I could make filename as C:\Program Files\Filebeat\test-kafka\test_csv.csv successfully but I want to name the file just as the file name not the whole directory. Did i miss something?

yuliansen
  • 470
  • 2
  • 14
  • 29
  • 2
    You probably need four backslashes. In a java string, you have to escape your backslash like you did. But when it gets to the regex engine, it's now just a single backslash. So four of them gives the regex engine a proper escaped backslash. – Gary Jul 08 '20 at 14:30
  • 1
    Please try [**```.+\\\\```**](https://regex101.com/r/GmymA6/6). Closing as a typo –  Jul 08 '20 at 14:33
  • it works thank you so much guys. – yuliansen Jul 09 '20 at 02:48

0 Answers0