vendredi 12 avril 2019

How to manipulate strings in a Telosys template


All Java objects methods can be used in a template (".vm" file),
hence it’s possible to use all the methods defined in the Java class “String”.



For all information about 'String' methods see the Java doc :
 https://docs.oracle.com/javase/7/docs/api/java/lang/String.html



Examples :


length is $STR.length()

#set($STR = $STR.replaceFirst("def", "xy" )

#if ( $STR.endsWith("ef") )
YES, it ends with "ef"
#else
NO
#end

charAt(2) : $STR.charAt(2)

#if ( $STR.equalsIgnoreCase($STR2) )
YES
#else
NO
#end


$STR.toUpperCase()
$STR.toLowerCase()


Aucun commentaire:

Enregistrer un commentaire