<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Split the string after 40 character in Talend Studio</title>
    <link>https://community.qlik.com/t5/Talend-Studio/Split-the-string-after-40-character/m-p/2293238#M66232</link>
    <description>&lt;P&gt;A routine like this will work. I've just knocked it up and it will need refining (it doesn't currently catch situations where the sentence size is smaller than the biggest word, for example). Have a play and refine as required....&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;B&gt;package&lt;/B&gt; routines;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;B&gt;public&lt;/B&gt; &lt;B&gt;class&lt;/B&gt; WholeWordSplit {&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&lt;B&gt;public&lt;/B&gt; &lt;B&gt;static&lt;/B&gt; String[] splitSentence(String sentence, &lt;B&gt;int&lt;/B&gt; sentenceSize) {&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;	&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;	String[] returnVal;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;	String[] vals = sentence.split(" ");&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;	&lt;B&gt;int&lt;/B&gt; size = 0;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;	java.util.ArrayList&amp;lt;String&amp;gt; columns = &lt;B&gt;new&lt;/B&gt; java.util.ArrayList&amp;lt;String&amp;gt;();&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;	&lt;B&gt;for&lt;/B&gt;(&lt;B&gt;int&lt;/B&gt; i=0; i&amp;lt; vals.length; i++){&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;		&lt;B&gt;if&lt;/B&gt;(columns.size()&amp;lt;1 || (size+vals[i].length()+1) &amp;gt; sentenceSize){&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;			columns.add(vals[i]);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;			size = vals[i].length();&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;		}&lt;B&gt;else&lt;/B&gt;{&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;			String tmpStr = columns.remove(columns.size()-1);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;			tmpStr = tmpStr+" "+ vals[i];&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;			columns.add(tmpStr);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;			size = tmpStr.length();&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;		&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;		}&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;	}&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;	&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;	returnVal = columns.toArray(&lt;B&gt;new&lt;/B&gt; String[columns.size()]);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;	&lt;B&gt;return&lt;/B&gt; returnVal;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;}&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;</description>
    <pubDate>Wed, 23 Mar 2022 20:54:41 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2022-03-23T20:54:41Z</dc:date>
    <item>
      <title>Split the string after 40 character</title>
      <link>https://community.qlik.com/t5/Talend-Studio/Split-the-string-after-40-character/m-p/2293237#M66231</link>
      <description>&lt;P&gt;I am extracting the name from Snowflake.&lt;/P&gt;&lt;P&gt;Name has more than 40 characters. To make this easy, I am going to split the name and put the first 40 characters in Col1 and the rest in Col 2. I'm worried about splitting the string in the middle of a word.&lt;/P&gt;&lt;P&gt;For example:&lt;/P&gt;&lt;P&gt;Name is : " Talend Advantage International Consulting Solutions LLC"&lt;/P&gt;&lt;P&gt;here i have 55 characters,&lt;/P&gt;&lt;P&gt;If i split the first 40 characters in col1 it will be "Talend Advantage International Consultin"&lt;/P&gt;&lt;P&gt;Instead, i want to have "Talend Advantage International" in col1 and &lt;/P&gt;&lt;P&gt;"Solutions LLC"  in col2&lt;/P&gt;&lt;P&gt;I want to avoid the middle word splitting.&lt;/P&gt;&lt;P&gt;Please help!!&lt;/P&gt;</description>
      <pubDate>Fri, 15 Nov 2024 23:05:42 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/Split-the-string-after-40-character/m-p/2293237#M66231</guid>
      <dc:creator>since_1995</dc:creator>
      <dc:date>2024-11-15T23:05:42Z</dc:date>
    </item>
    <item>
      <title>Re: Split the string after 40 character</title>
      <link>https://community.qlik.com/t5/Talend-Studio/Split-the-string-after-40-character/m-p/2293238#M66232</link>
      <description>&lt;P&gt;A routine like this will work. I've just knocked it up and it will need refining (it doesn't currently catch situations where the sentence size is smaller than the biggest word, for example). Have a play and refine as required....&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;B&gt;package&lt;/B&gt; routines;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;B&gt;public&lt;/B&gt; &lt;B&gt;class&lt;/B&gt; WholeWordSplit {&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&lt;B&gt;public&lt;/B&gt; &lt;B&gt;static&lt;/B&gt; String[] splitSentence(String sentence, &lt;B&gt;int&lt;/B&gt; sentenceSize) {&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;	&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;	String[] returnVal;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;	String[] vals = sentence.split(" ");&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;	&lt;B&gt;int&lt;/B&gt; size = 0;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;	java.util.ArrayList&amp;lt;String&amp;gt; columns = &lt;B&gt;new&lt;/B&gt; java.util.ArrayList&amp;lt;String&amp;gt;();&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;	&lt;B&gt;for&lt;/B&gt;(&lt;B&gt;int&lt;/B&gt; i=0; i&amp;lt; vals.length; i++){&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;		&lt;B&gt;if&lt;/B&gt;(columns.size()&amp;lt;1 || (size+vals[i].length()+1) &amp;gt; sentenceSize){&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;			columns.add(vals[i]);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;			size = vals[i].length();&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;		}&lt;B&gt;else&lt;/B&gt;{&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;			String tmpStr = columns.remove(columns.size()-1);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;			tmpStr = tmpStr+" "+ vals[i];&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;			columns.add(tmpStr);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;			size = tmpStr.length();&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;		&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;		}&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;	}&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;	&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;	returnVal = columns.toArray(&lt;B&gt;new&lt;/B&gt; String[columns.size()]);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;	&lt;B&gt;return&lt;/B&gt; returnVal;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;}&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;</description>
      <pubDate>Wed, 23 Mar 2022 20:54:41 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/Split-the-string-after-40-character/m-p/2293238#M66232</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2022-03-23T20:54:41Z</dc:date>
    </item>
  </channel>
</rss>

