Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

substring function

Status
Not open for further replies.

lancien

IS-IT--Management
Aug 17, 2007
3
FR
A developper has to code in e*Gate the following rule :
"take the 20 first characters of a string".

He say me that he use a substring function and that this function launch an exception if the initial string has less than 20 characters. For me the function should return the whole string if it is smaller than 20.
Is it a "normal" behaviour of the substring function or is it a bad use made by the developper ?

Thanks by advance.
 
in java in would work as you expected, monk is a little bit stange.

but like this it would work:

trim(substr(catinate(str_to_trunc,' '),1,20))

 
I don't know.

Can you answer for one (or for the 2 langages) ?

Thanks.
 
Thanks for your answer.

A last question : how many spaces in the string following str_to_trunc of the monk code ?

trim(substr(catinate(str_to_trunc,' '),1,20))
 
at least 20 spaces. Like this, the string is at least 20 characers, you cut out the first 20, and with trim you eliminate the remaining spaces.

if the language would be java and your programmer use offical java routins (not own developped stuff) then it would work properly.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top