Tuesday 30 July 2024

Check first char is string or number

 To check if the first character is number or string: 

 

import com.sap.gateway.ip.core.customdev.util.Message;

import java.util.HashMap;

def Message processData(Message message) {

    //Body

       def body = message.getBody(java.lang.String);

            def firstChar = body.substring(0..1)

 

            if (firstChar.matches("[0-9]+")){

    number= "true"

}else

{

    number = "false"

}

            message.setProperty("number",number)

       return message;

}




No comments:

Post a Comment