<?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: [resolved] Extract string before a special character in Talend Studio</title>
    <link>https://community.qlik.com/t5/Talend-Studio/resolved-Extract-string-before-a-special-character/m-p/2362436#M126574</link>
    <description>If the scenario is that you also have the records that do not contain the character "(" and say if you want to pass them as it is to the output you can try out the below code in tJavaRow (You need to modify it as per your case): 
&lt;BR /&gt; 
&lt;PRE&gt;if((input_row.Country) != null &amp;amp;&amp;amp; ((String)input_row.Country).contains("("))&lt;BR /&gt;output_row.Country = StringHandling.LEFT(input_row.Country,StringHandling.INDEX(input_row.Country,"("));&lt;BR /&gt;else if((input_row.Country) != null &amp;amp;&amp;amp; !((String)input_row.Country).contains("("))&lt;BR /&gt;output_row.Country = input_row.Country;&lt;/PRE&gt;</description>
    <pubDate>Tue, 26 Feb 2013 06:08:54 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2013-02-26T06:08:54Z</dc:date>
    <item>
      <title>[resolved] Extract string before a special character</title>
      <link>https://community.qlik.com/t5/Talend-Studio/resolved-Extract-string-before-a-special-character/m-p/2362432#M126570</link>
      <description>Hi, &lt;BR /&gt;I am trying to extract string before any special character. How can I do that?&lt;BR /&gt;For example:&lt;BR /&gt;Column1&lt;BR /&gt;india (451,98)&lt;BR /&gt;abc (123.43)&lt;BR /&gt;resd (34,56)&lt;BR /&gt;Expected Output:&lt;BR /&gt;Column1&lt;BR /&gt;india&lt;BR /&gt;abc&lt;BR /&gt;resd&lt;BR /&gt;I am trying with the java code(tjavarow), But it is showing me the following error:-&lt;BR /&gt;statistics] connecting to socket on port 3837&lt;BR /&gt; connected&lt;BR /&gt;Exception in component tJavaRow_1&lt;BR /&gt;java.lang.StringIndexOutOfBoundsException: String index out of range: -1&lt;BR /&gt;	at java.lang.String.substring(Unknown Source)&lt;BR /&gt;	at roamware.copy_of_rw_add_country_code_0_1.Copy_of_RW_Add_Country_Code.tOracleInput_1Process(Copy_of_RW_Add_Country_Code.java:893)&lt;BR /&gt;	at roamware.copy_of_rw_add_country_code_0_1.Copy_of_RW_Add_Country_Code.runJobInTOS(Copy_of_RW_Add_Country_Code.java:1271)&lt;BR /&gt;	at roamware.copy_of_rw_add_country_code_0_1.Copy_of_RW_Add_Country_Code.main(Copy_of_RW_Add_Country_Code.java:1139)&lt;BR /&gt;My code is as follow:-&lt;BR /&gt;output_row.Country = Relational.ISNULL(input_row.COUNTRYNAME)?"":input_row.COUNTRYNAME.trim().length()&amp;gt;0?input_row.COUNTRYNAME.trim().substring(0,input_row.COUNTRYNAME.indexOf("(")): input_row.COUNTRYNAME.trim();</description>
      <pubDate>Mon, 25 Feb 2013 13:09:28 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/resolved-Extract-string-before-a-special-character/m-p/2362432#M126570</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2013-02-25T13:09:28Z</dc:date>
    </item>
    <item>
      <title>Re: [resolved] Extract string before a special character</title>
      <link>https://community.qlik.com/t5/Talend-Studio/resolved-Extract-string-before-a-special-character/m-p/2362433#M126571</link>
      <description>Hi,
&lt;BR /&gt;you could try :
&lt;BR /&gt;
&lt;PRE&gt;StringHandling.LEFT(row1.newColumn,StringHandling.INDEX(row1.newColumn,"("))&lt;/PRE&gt;</description>
      <pubDate>Mon, 25 Feb 2013 13:48:37 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/resolved-Extract-string-before-a-special-character/m-p/2362433#M126571</guid>
      <dc:creator>NicolasTT</dc:creator>
      <dc:date>2013-02-25T13:48:37Z</dc:date>
    </item>
    <item>
      <title>Re: [resolved] Extract string before a special character</title>
      <link>https://community.qlik.com/t5/Talend-Studio/resolved-Extract-string-before-a-special-character/m-p/2362434#M126572</link>
      <description>Hi, This is still showing me the following error:-
&lt;BR /&gt;Exception in component tJavaRow_1
&lt;BR /&gt;java.lang.StringIndexOutOfBoundsException: String index out of range: -1
&lt;BR /&gt; at java.lang.String.substring(Unknown Source)
&lt;BR /&gt; at routines.StringHandling.LEFT(StringHandling.java:218)
&lt;BR /&gt; at roamware.copy_of_rw_add_country_code_0_1.Copy_of_RW_Add_Country_Code.tOracleInput_1Process(Copy_of_RW_Add_Country_Code.java:891)
&lt;BR /&gt; at roamware.copy_of_rw_add_country_code_0_1.Copy_of_RW_Add_Country_Code.runJobInTOS(Copy_of_RW_Add_Country_Code.java:1268)
&lt;BR /&gt; at roamware.copy_of_rw_add_country_code_0_1.Copy_of_RW_Add_Country_Code.main(Copy_of_RW_Add_Country_Code.java:1136)
&lt;BR /&gt;
&lt;BR /&gt;
&lt;BLOCKQUOTE&gt;
 &lt;TABLE border="1"&gt;
  &lt;TBODY&gt;
   &lt;TR&gt;
    &lt;TD&gt;Hi,&lt;BR /&gt;you could try :&lt;BR /&gt;&lt;PRE&gt;StringHandling.LEFT(row1.newColumn,StringHandling.INDEX(row1.newColumn,"("))&lt;/PRE&gt;&lt;BR /&gt;&lt;/TD&gt;
   &lt;/TR&gt;
  &lt;/TBODY&gt;
 &lt;/TABLE&gt;
&lt;/BLOCKQUOTE&gt;</description>
      <pubDate>Tue, 26 Feb 2013 04:11:06 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/resolved-Extract-string-before-a-special-character/m-p/2362434#M126572</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2013-02-26T04:11:06Z</dc:date>
    </item>
    <item>
      <title>Re: [resolved] Extract string before a special character</title>
      <link>https://community.qlik.com/t5/Talend-Studio/resolved-Extract-string-before-a-special-character/m-p/2362435#M126573</link>
      <description>&lt;BLOCKQUOTE&gt;
 &lt;TABLE border="1"&gt;
  &lt;TBODY&gt;
   &lt;TR&gt;
    &lt;TD&gt;Hi, This is still showing me the following error:-&lt;BR /&gt;Exception in component tJavaRow_1&lt;BR /&gt;java.lang.StringIndexOutOfBoundsException: String index out of range: -1&lt;BR /&gt; at java.lang.String.substring(Unknown Source)&lt;BR /&gt; at routines.StringHandling.LEFT(StringHandling.java:218)&lt;BR /&gt; at roamware.copy_of_rw_add_country_code_0_1.Copy_of_RW_Add_Country_Code.tOracleInput_1Process(Copy_of_RW_Add_Country_Code.java:891)&lt;BR /&gt; at roamware.copy_of_rw_add_country_code_0_1.Copy_of_RW_Add_Country_Code.runJobInTOS(Copy_of_RW_Add_Country_Code.java:1268)&lt;BR /&gt; at roamware.copy_of_rw_add_country_code_0_1.Copy_of_RW_Add_Country_Code.main(Copy_of_RW_Add_Country_Code.java:1136)&lt;/TD&gt;
   &lt;/TR&gt;
  &lt;/TBODY&gt;
 &lt;/TABLE&gt;
&lt;/BLOCKQUOTE&gt;
&lt;BR /&gt;Hi,
&lt;BR /&gt;This error might be because some of your input records don't have the character "(" which we are using in the StringHandling function. Let us know if that is the case.
&lt;BR /&gt;Regards,
&lt;BR /&gt;Diwakar</description>
      <pubDate>Tue, 26 Feb 2013 05:54:36 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/resolved-Extract-string-before-a-special-character/m-p/2362435#M126573</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2013-02-26T05:54:36Z</dc:date>
    </item>
    <item>
      <title>Re: [resolved] Extract string before a special character</title>
      <link>https://community.qlik.com/t5/Talend-Studio/resolved-Extract-string-before-a-special-character/m-p/2362436#M126574</link>
      <description>If the scenario is that you also have the records that do not contain the character "(" and say if you want to pass them as it is to the output you can try out the below code in tJavaRow (You need to modify it as per your case): 
&lt;BR /&gt; 
&lt;PRE&gt;if((input_row.Country) != null &amp;amp;&amp;amp; ((String)input_row.Country).contains("("))&lt;BR /&gt;output_row.Country = StringHandling.LEFT(input_row.Country,StringHandling.INDEX(input_row.Country,"("));&lt;BR /&gt;else if((input_row.Country) != null &amp;amp;&amp;amp; !((String)input_row.Country).contains("("))&lt;BR /&gt;output_row.Country = input_row.Country;&lt;/PRE&gt;</description>
      <pubDate>Tue, 26 Feb 2013 06:08:54 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/resolved-Extract-string-before-a-special-character/m-p/2362436#M126574</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2013-02-26T06:08:54Z</dc:date>
    </item>
    <item>
      <title>Re: [resolved] Extract string before a special character</title>
      <link>https://community.qlik.com/t5/Talend-Studio/resolved-Extract-string-before-a-special-character/m-p/2362437#M126575</link>
      <description>Hi, Thanks a lot. 
&lt;BR /&gt;It is working fine now with this code. Thanks 
&lt;BR /&gt; 
&lt;BR /&gt; 
&lt;BLOCKQUOTE&gt; 
 &lt;TABLE border="1"&gt; 
  &lt;TBODY&gt; 
   &lt;TR&gt; 
    &lt;TD&gt;If the scenario is that you also have the records that do not contain the character "(" and say if you want to pass them as it is to the output you can try out the below code in tJavaRow (You need to modify it as per your case):&lt;BR /&gt;&lt;PRE&gt;if((input_row.Country) != null &amp;amp;&amp;amp; ((String)input_row.Country).contains("("))&lt;BR /&gt;output_row.Country = StringHandling.LEFT(input_row.Country,StringHandling.INDEX(input_row.Country,"("));&lt;BR /&gt;else if((input_row.Country) != null &amp;amp;&amp;amp; !((String)input_row.Country).contains("("))&lt;BR /&gt;output_row.Country = input_row.Country;&lt;/PRE&gt;&lt;BR /&gt;&lt;/TD&gt; 
   &lt;/TR&gt; 
  &lt;/TBODY&gt; 
 &lt;/TABLE&gt; 
&lt;/BLOCKQUOTE&gt;</description>
      <pubDate>Tue, 26 Feb 2013 09:23:43 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/resolved-Extract-string-before-a-special-character/m-p/2362437#M126575</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2013-02-26T09:23:43Z</dc:date>
    </item>
    <item>
      <title>Re: [resolved] Extract string before a special character</title>
      <link>https://community.qlik.com/t5/Talend-Studio/resolved-Extract-string-before-a-special-character/m-p/2362438#M126576</link>
      <description>That's great.. You're welcome 
&lt;span class="lia-inline-image-display-wrapper" image-alt="0683p000009MACn.png"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/154443iC5B8CACEF3D12C6A/image-size/large?v=v2&amp;amp;px=999" role="button" title="0683p000009MACn.png" alt="0683p000009MACn.png" /&gt;&lt;/span&gt; 
&lt;BR /&gt;Best Regards, 
&lt;BR /&gt;Diwakar</description>
      <pubDate>Tue, 26 Feb 2013 09:55:03 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/resolved-Extract-string-before-a-special-character/m-p/2362438#M126576</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2013-02-26T09:55:03Z</dc:date>
    </item>
    <item>
      <title>Re: [resolved] Extract string before a special character</title>
      <link>https://community.qlik.com/t5/Talend-Studio/resolved-Extract-string-before-a-special-character/m-p/2362439#M126577</link>
      <description>You can mark this post as resolved.&lt;BR /&gt;Regards,&lt;BR /&gt;Diwakar</description>
      <pubDate>Tue, 26 Feb 2013 10:23:49 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/resolved-Extract-string-before-a-special-character/m-p/2362439#M126577</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2013-02-26T10:23:49Z</dc:date>
    </item>
    <item>
      <title>Re: [resolved] Extract string before a special character</title>
      <link>https://community.qlik.com/t5/Talend-Studio/resolved-Extract-string-before-a-special-character/m-p/2362440#M126578</link>
      <description>i have a simmilar question, i get API with tRESTClient in JSON, when i use the API link directly in the browser it works fine.
&lt;BR /&gt;when i use tRESTClient ---&amp;gt; tLogRow i get the same JSON, exept for the first part of the string, Talend added: '200||' to the string. so because of that i cannot use tExtractJSONFields because the JSON is invalid.
&lt;BR /&gt;how can i extract the first five characters, in this case: '200||', from the string (JSON)??</description>
      <pubDate>Thu, 06 Oct 2016 10:35:58 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/resolved-Extract-string-before-a-special-character/m-p/2362440#M126578</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2016-10-06T10:35:58Z</dc:date>
    </item>
    <item>
      <title>Re: [resolved] Extract string before a special character</title>
      <link>https://community.qlik.com/t5/Talend-Studio/resolved-Extract-string-before-a-special-character/m-p/2362441#M126579</link>
      <description>&lt;P&gt;I used exactly this code and keep getting the error: &lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;I&gt;Exception in component tJavaRow_1 (Extract_Country_Code)&lt;/I&gt;&lt;/P&gt;&lt;P&gt;&lt;I&gt;java.lang.StringIndexOutOfBoundsException: Range [0, -1) out of bounds for length 15&lt;/I&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Do you have any idea why and what I can do? I cannot find any solution for this in the forum. &lt;/P&gt;&lt;P&gt;Thank you!&lt;/P&gt;</description>
      <pubDate>Tue, 04 Oct 2022 08:43:40 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/resolved-Extract-string-before-a-special-character/m-p/2362441#M126579</guid>
      <dc:creator>Moro</dc:creator>
      <dc:date>2022-10-04T08:43:40Z</dc:date>
    </item>
  </channel>
</rss>

