AnsweredAssumed Answered

String prefix removal dynamically

Question asked by allah.bakshu.shaik802907 on Sep 7, 2018
Latest reply on Sep 7, 2018 by trey.yeager826393

Hi,

Is there any issue with below groovy script? I am using this script in map to remove the prefix in the input string (Input_GRP) but result coming as null value. This script is working fine when I execute in  groovy editor: https://www.jdoodle.com/execute-groovy- 

 

Input patterns like below:

 

APP_BAPP_ADAPP_MIN

APP_UAPP_USER

APP_CAPP_APP_ROLE

 

Expected Result:
BAPP_ADAPP_MIN

UAPP_USER

CAPP_APP_ROLE

--------------------------------


def prefix = 'APP_';
def Input_GRP = '';
def result='';

if (Input_GRP.startsWith(prefix)) {
result = Input_GRP.substring(prefix.size())

print result
}

 

Script result in Groovy editor

Outcomes