[resolved] How to Substring a Large String in tMap

Highlighted
Six Stars

[resolved] How to Substring a Large String in tMap

Neither of these worked in tMap Expression Builder for strings larger than 46 characters. It seems that strings larger than 46 characters cannot be operated on. Is that correct?
This is what I'm trying to do. Through experimentation, it seems to throw errors once the "index" or "indexOf" is bigger than 46.
StringHandling.LEFT(row11.out,StringHandling.INDEX(row11.out,"=")) 
row11.out.substring(0, row11.out.indexOf("=")) 
For both I get a 
"String index out of range: -1
java.lang.StringIndexOutOfBoundsException: String index out of range: -1"
Does anyone know why it would do this? 

Accepted Solutions
Highlighted
Ten Stars

Re: [resolved] How to Substring a Large String in tMap

Strings should not be constrained to 46 characters.  Is it possible your schema is defining that column of input with length 46?
StringHandling.INDEX will return -1 if either of its arguments are null.  Are there any cases where row11.out is null?
indexOf returns -1 if the searched for character is not found.  Are there any instancens where row11.out does not contain "="?

View solution in original post


All Replies
Highlighted
Ten Stars

Re: [resolved] How to Substring a Large String in tMap

Strings should not be constrained to 46 characters.  Is it possible your schema is defining that column of input with length 46?
StringHandling.INDEX will return -1 if either of its arguments are null.  Are there any cases where row11.out is null?
indexOf returns -1 if the searched for character is not found.  Are there any instancens where row11.out does not contain "="?

View solution in original post

Highlighted
Six Stars

Re: [resolved] How to Substring a Large String in tMap

I think that, in the end, that some of the strings I had were null. 
The thing is that I didn't expect them in the output but I guess that is what happens sometimes! haha
Thanks,
Croix

2019 GARTNER MAGIC QUADRANT FOR DATA INTEGRATION TOOL

Talend named a Leader.

Get your copy

OPEN STUDIO FOR DATA INTEGRATION

Kickstart your first data integration and ETL projects.

Download now

Best Practices for Using Context Variables with Talend – Part 2

Part 2 of a series on Context Variables

Blog

Best Practices for Using Context Variables with Talend – Part 1

Learn how to do cool things with Context Variables

Blog

Migrate Data from one Database to another with one Job using the Dynamic Schema

Find out how to migrate from one database to another using the Dynamic schema

Blog