Details
-
New Feature
-
Status: Resolved
-
Minor
-
Resolution: Fixed
-
1.9.2
-
None
Description
Current Situation
- Expression Language string manipulation doesn't have anything to perform string padding
- Existing solutions to achieve left or right padding are unintuitive
- Es: ${prop:prepend('0000'):substring(${prop:length()},${prop:length():plus(4)})}
Improvement Proposal
- Support two new expression language methods
- padLeft:
- padLeft(int n) will prepend a default character to of the input string until it reaches the length n
- padLeft(int n, char c) will prepend the c characters to the input string until it reaches the length n
- padRight:
- padRight(int n) will append a default character to the input string until it reaches the length n
- padRight(int n, char c) will append the c character to the input string until it reaches the length n
- Default character should be a renderable character such as underscore
- If the input string is already longer than the padding length, no operation should be performed
- padLeft:
Examples
input = "myString"
- ${input:padLeft(10, '#')} => "##myString"
- ${input:padRight(10, '#')} => "myString##"
- ${input:padLeft(10)} => "__myString"
- ${input:padRight(10)} => "myString__"
Attachments
Issue Links
- links to