How to get the first letter in a string

How to get the first letter in a string

book

Article ID: KB0075736

calendar_today

Updated On:

Products Versions
TIBCO Streaming 7.x

Description

How can I get the first letter in a string using the StreamBase Expression Language?

Issue/Introduction

How to get the first letter in a string

Resolution

Use the substr function, as described in the Help under StreamBase Home > StreamBase References > StreamBase Expression Language Functions.  For example:
 
>> sbd --eval "substr('ABC',0,1)"
(string) A


In the above example, the first argument, ABC, is the parent string.  The second argument specifies the sub-string's start position in the parent string.  In this case it's 0 because we want the first character.  The last argument specifies the sub-string's total length.  In this case, it's 1.