You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@nifi.apache.org by "Matt Burgess (Jira)" <ji...@apache.org> on 2019/10/17 16:19:00 UTC
[jira] [Comment Edited] (NIFI-6782) Create EL function for
repeating a string
[ https://issues.apache.org/jira/browse/NIFI-6782?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16953883#comment-16953883 ]
Matt Burgess edited comment on NIFI-6782 at 10/17/19 4:18 PM:
--------------------------------------------------------------
It doesn't look like we support function overloading, but I'll try to add two functions with the same name but different arity. If it's not supported I'll implement the 1-arg function as described above.
EDIT: I found out it can be done, the parser would look for "repeat" as a 2-arg function but the second one is optional. The "substring" function is done this way so I'll use that as a guide.
was (Author: mattyb149):
It doesn't look like we support function overloading, but I'll try to add two functions with the same name but different arity. If it's not supported I'll implement the 1-arg function as described above.
> Create EL function for repeating a string
> -----------------------------------------
>
> Key: NIFI-6782
> URL: https://issues.apache.org/jira/browse/NIFI-6782
> Project: Apache NiFi
> Issue Type: New Feature
> Components: Extensions
> Affects Versions: 1.9.2
> Reporter: Andy LoPresto
> Assignee: Matt Burgess
> Priority: Minor
> Labels: expression-language, string-manipulation
>
> As per a discussion with [~mattyb149], an Expression Language function which allowed for a number of repetitions of a string would be useful for generating arbitrary random text in a {{GenerateFlowFile}} processor. The usage would be:
> {code}
> ${"some string here":repeat(4)} # repeats the literal string 4 times
> ${literal("this_is_also_an_attribute_name"):repeat(3)} # repeats the literal string 3 times
> ${my_string_attr:repeat(5)} # repeats the value in the attribute 5 times
> ${"explicit string":repeat(random():mod(10):plus(1))} # repeats the string between 1 and 10 times
> {code}
> If it's easy to implement, I think a multiple parameter option would also be convenient, but it is not a requirement:
> {code}
> ${"explicit string":repeat(random():mod(10):plus(1))} # repeats the string between 1 and 10 times
> ${"explicit string":repeat(1, 10)} # identical behavior to above
> {code}
--
This message was sent by Atlassian Jira
(v8.3.4#803005)