Hi ,
I have to trim a string not using JS . is there a way to do that using ootb policy
Regards,
Patty
Solved! Go to Solution.
MessageTemplates also have a replaceAll function that you could use
You're looking for the `substring` function that is available as a Message Template. See https://cloud.google.com/apigee/docs/api-platform/reference/message-template-intro#substring-functio...
Here is a sample to get you started:
<AssignMessage name="AM-Substring">
<IgnoreUnresolvedVariables>true</IgnoreUnresolvedVariables>
<AssignVariable>
<Name>originalString</Name>
<Value>ABCDEFGHIJKLMNOPQRSTUVWXYZ</Value>
</AssignVariable>
<AssignVariable>
<Name>start_index</Name>
<Value>0</Value>
</AssignVariable>
<AssignVariable>
<Name>end_index</Name>
<Value>3</Value>
</AssignVariable>
<AssignVariable>
<Name>trimmedString</Name>
<Template>{substring(originalString,start_index,end_index)}</Template>
</AssignVariable>
<AssignVariable>
<Name>literalString</Name>
<Template>{substring(ABCDEFGHIJKLMNOPQRSTUVWXYZ,0,3)}</Template>
</AssignVariable>
</AssignMessage>
Hi ,
Actually needs to remove leading and trailing space character from a string .
Ex - originalString = " ABCGDFLFLFF "
trimmedString = ABCGDFLFLFF
Best Regards,
Patty
MessageTemplates also have a replaceAll function that you could use