Search code examples
apache-nifi

Why is there an error on the colon in ${attribute:find...?


I want to use RouteOnAttribute to filter on a regex. To do so, I added two attributes in the Properties:

Property Value
private ${ip:find('^(10|127|169\.254|172\.1[6-9]|172\.2[0-9]|172\.3[0-1]|192\.168)\.')}
public ${ip:find('^([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])(?<!172\.(16|17|18|19|20|21|22|23|24|25|26|27|28|29|30|31))(?<!127)(?<!^10)(?<!^0)\.([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])(?<!192\.168)(?<!172\.(16|17|18|19|20|21|22|23|24|25|26|27|28|29|30|31))\.([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])$')}

This processor shows two errors, both the same: Unexpected token ':' at line 1 column 4

Why is this an error?


Solution

  • There is an expression language function called ip. Try quoting the "ip" (single or double should be supported) and it should parse it as a FlowFile attribute and not a function name.