How flexible is the flexible is the Flow language with regard to string manipulation. Lets say the
input to the service is a String. I need to loop
through this string and insert a delimiter after
every 35 characters until the end of the string.
How would I do this using only the flow constructs and
built-in services? I do not want to write a java program/service to do this.
There are many ways to do this. Off the top of my head:
-Repeat (while success)
-Get the input String length
-Branch
-exit loop if strlen < 35
-map (break the string into 2 parts using 2 substring transformers - the two parts are the first 35 and the rest of the string. assign the 2nd part to the original input string)
-concatenate the first 35 character to the output string
- concatenate the delimiter to the output string
-append any leftover chars to the output string: Note that this last step is outside of the repeat loop
Your best bet is probably to use the built in pub.string:substring and pub.string:concat within your loops (and the neccessary branches on the length of the string, etc).
The only thing is it will be VERY inefficient to use a flow service when you get into parsing large strings. Unless there you cannot use java services under any circumstances, I would suggest writing this in java. That way you can use StringBuffers and more ‘native’ java string manipulation.