Fun with String Manipulation's "undocumented features"

For a while now I’ve been using various features of String Manipulation that you won’t generally find documented. I guess therefore, that what I am writing here should be given the caveat “use at your own risk” since it is always possible that in the future, the String Manipulation (and its “(variable)” counterpart node) could be rewritten and the undocumented features would no longer work.

However, since it sits on top of java, and these features make use of its close relationship with java, it is probably fair to assume that this will continue to work in future.

The interesting (to me at least) thing about String Manipulation… at least what I can ascertain from experimenting… is that behind the scenes it uses a java “return” statement, which it then parses to handle all of the String Manipulation syntax. If that return statement contains java-syntax, it is unaffected, and so what I have gathered is that provided what you throw at String Manipulation can syntactically fit into a java return statement, the world is your oyster!

Conditional Expressions.
This is something I do often with String Manipulation as I find it very convenient for simple conditions. see this forum post for details of how nested conditional expressions can be included in String Manipulation:

Random Number generator
A random number can be generated in Java using the standard Random() call. An integer between lower bounday n and upper boundary m inclusive can be produced using:
new Random()).nextInt(m) + n

so a random number between 1 and 6 can be returned by String Manipulation as follows:

(new Random()).nextInt(6) +1 

Current Date and Time

Java can produce current date and time as a string simply by instantiating a new Date() object, and returning it as a String. So in String Manipulation, current date and time can be returned by:

	new Date()

Universal Unique Identifers (UUIDs)

If you have need of returning a UUID you can use the java UUID package to return a random UUID:



Attached is a demo workflow showcasing the above

FunWithStringManipulation.knwf (14.5 KB)

I hope that was of interest. What other simple functions would you find this useful for?

[Edit: I’ve re-uploaded the demo workflow as the nested conditions had a typo]


Mathematical Capabilities

“mathematical capabilities of String Manipulation are often overlooked. Its name is a a misnomer because it can handle (to an extent) numeric calculations too, even being able to return them via the toInt, toLong and toDouble functions.” (Master @takbb )



Great sharing as always @takbb !