Maybe it’s the java way of doing things, but I have NEVER liked the way the substring function needs two indices to work, rather than a starting location and a length.
If Vlad is reading this and he happens to go into the code,
Sure would be nice to create a new SUBSTRING2 function with the syntax:
SUBSTRING2 ( string, starting-pos, length )
And the Java function was smart enough to not crap out if the length exceeded the actually field length.
And It would accept a negative value to remove characters from the right trimmed end.
Extracting the value in the parens here is overly complex.
TheString = ‘jaymer jaymer (jj)’
Initials = substring( TheString, index( TheString, ‘(‘ ) + 1 , index( TheString, ‘)‘ ) )
Using “-1” here would use remaining string minus 1 character
TheString = ‘widget - item1234’
partnum = substring( TheString, index( TheString, ‘-‘ ) + 2 , length( trim(TheString)) )
(Omitting length here would go to end of string)
One thing about JavaScript libraries or newer languages (GO as an example, but it’s not necessarily “New”) is they streamline functions for us. This substring was coded over 10 years ago and hasn’t improved. We know Vlad can do things like this USUALLY, but not limited to, when he needs a function in his own projects or an improvement in aware (like output to “same panel” was needed to handle the input controls in a toolbar). And he recently added JSON_PATH which was nice.