CyLog Software Homepage BeanMaker v2.10
Copyright 2000-2006 CyLog Software
Introduction
Quick Guide
How the engine works
Writing Templates
   Standard Tags
   Property Loop Tags
   Switch Tags
   Include File Tag
   Regular Expression Tag
   String Function Tags
   Numeric Function Tags
   
Tutorials
Registration
License Agreement

Writing Templates - String Function Tags

BeanMaker support a few strings function to help you perform simple string manipulation.

LowerCase conversion:
    $lower('string')$

UpperCase conversion:
    $upper('string')$

Sub-Strings:
    $substr('string', starting index, number of characters)$

Right-Pad:
    $rpad('string', number of characters)$

Left-Pad:
    $lpad('string', number of characters)$

Zero-Pad:
    $zeropad(numeric value, number of characters)$

Equals:
    $equals('string value 1', 'string value 2', 'true result', 'false result')$
Returns the 'true result' if the first string is equal to the second string, otherwise it returns the 'false result'

Pos:
    $pos('sub string', 'main string')$
Returns 0 if 'sub string' is not contained in 'main string', otherwise the position of the main string in which the first occurence sub string starts (1..n, where n the length of the main string in chars)

Last Pos:
    $lastpos('sub string', 'main string')$
Returns 0 if 'sub string' is not contained in 'main string', otherwise the position of the main string in which the last occurence of sub string starts (1..n, where n the length of the main string in chars

The string parameters in the above functions can contain string constants, BeanMaker's tags or even other functions. Examples:

$lower('Java')$         => java
$upper('Hello World')$  => HELLO WORLD
$upper('$class$')$      => convert the representation of the $class$ tag to upper case

$substr('cylog',1,2)$   => "cy"
$substr('cylog',1,200)$ => "cylog"  (returns all remaining characters)
$substr('cylog',3,2)$   => "lo"     (returns 2 characters starting from the 3rd character)
$substr('cylog',3,0)$   => ""       (empty string)
$substr('cylog',1,1)$   => "c"      (first char)
$substr('cylog',2,1)$   => "y"      (second char)
$substr('cylog',3,1)$   => "l"      (third char)
$substr('cylog',4,1)$   => "o"      (fourth char)
$substr('cylog',5,1)$   => "g"      (fifth char)
$substr('cylog',6,1)$   => ""       (no chars at position 6)

$rpad('cylog',8)$   => "cylog   "     
$lpad('cylog',8)$   => "   cylog"     

$zeropad(1,4)$      => "0001"
$zeropad(22,4)$     => "0022"
$zeropad(123,2)$    => "123"        (number is longer than the requested number of chars)

$equals('$index$','0', 'zero','not zero')$   =>   "zero" when the $index$ tag is "0", "not zero" otherwise 

$pos('x','banana')$      => "0"
$lastpos('x','banana')$  => "0"
$pos('a','banana')$      => "2"
$lastpos('a','banana')$  => "6"
$pos('ana','banana')$      => "2"
$lastpos('ana','banana')$  => "4"

To convert to lower caser the first letter of a property, do this:

$upper('$substr('$property$',1,1)$')$$substr('$property$',2,255)$

Explanation:
        $substr('$property$',1,1)$                                  => the first letter or the property
$upper('                          ')$                               => uppercase of the first letter
                                     $substr('$property$',2,255)$   => the rest of the property string
Copyright 2000-2006 CyLog Software    www.cylog.org