<?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] keep last part of string after a character (or substring) in Talend Studio</title>
    <link>https://community.qlik.com/t5/Talend-Studio/resolved-keep-last-part-of-string-after-a-character-or-substring/m-p/2338192#M106453</link>
    <description>create a routine called my_routines and paste the code in to replace what's auto generated for the example routine.
&lt;BR /&gt;This gives
&lt;BR /&gt;package routines;
&lt;BR /&gt;/*
&lt;BR /&gt; * user specification: the function's comment should contain keys as follows: 1. write about the function's comment.but
&lt;BR /&gt; * it must be before the "{talendTypes}" key.
&lt;BR /&gt; * 
&lt;BR /&gt; * 2. {talendTypes} 's value must be talend Type, it is required . its value should be one of: String, char | Character,
&lt;BR /&gt; * long | Long, int | Integer, boolean | Boolean, byte | Byte, Date, double | Double, float | Float, Object, short |
&lt;BR /&gt; * Short
&lt;BR /&gt; * 
&lt;BR /&gt; * 3. {Category} define a category for the Function. it is required. its value is user-defined .
&lt;BR /&gt; * 
&lt;BR /&gt; * 4. {param} 's format is: {param} &amp;lt;type&amp;gt; &amp;lt;name&amp;gt;
&lt;BR /&gt; * 
&lt;BR /&gt; * &amp;lt;type&amp;gt; 's value should be one of: string, int, list, double, object, boolean, long, char, date. &amp;lt;name&amp;gt;'s value is the
&lt;BR /&gt; * Function's parameter name. the {param} is optional. so if you the Function without the parameters. the {param} don't
&lt;BR /&gt; * added. you can have many parameters for the Function.
&lt;BR /&gt; * 
&lt;BR /&gt; * 5. {example} gives a example for the Function. it is optional.
&lt;BR /&gt; */
&lt;BR /&gt;public class my_routines {
&lt;BR /&gt; /**
&lt;BR /&gt; * reverseIt() Reverses a string.
&lt;BR /&gt; *
&lt;BR /&gt; * {talendTypes} String
&lt;BR /&gt; *
&lt;BR /&gt; * {Category}my_routines
&lt;BR /&gt; *
&lt;BR /&gt; * {param} string ("fred") input: the string to be reversed
&lt;BR /&gt; *
&lt;BR /&gt; * {example} reverseIt("fred") # derf
&lt;BR /&gt; *
&lt;BR /&gt; */
&lt;BR /&gt; public static String reverseIt(String source) {
&lt;BR /&gt; int i, len = source.length();
&lt;BR /&gt; StringBuffer dest = new StringBuffer(len);
&lt;BR /&gt; for (i = (len - 1); i &amp;gt;= 0; i--)
&lt;BR /&gt; dest.append(source.charAt(i));
&lt;BR /&gt; return dest.toString();
&lt;BR /&gt; }
&lt;BR /&gt;}</description>
    <pubDate>Tue, 23 Jul 2013 16:54:55 GMT</pubDate>
    <dc:creator>janhess</dc:creator>
    <dc:date>2013-07-23T16:54:55Z</dc:date>
    <item>
      <title>[resolved] keep last part of string after a character (or substring)</title>
      <link>https://community.qlik.com/t5/Talend-Studio/resolved-keep-last-part-of-string-after-a-character-or-substring/m-p/2338188#M106449</link>
      <description>Hi, 
&lt;BR /&gt;Trying to get the last part of a string, in this case it's a url: 
&lt;BR /&gt; 
&lt;A href="http://mydomain.com/abc-defg/filename" target="_blank" rel="nofollow noopener noreferrer"&gt;http://mydomain.com/abc-defg/filename&lt;/A&gt; 
&lt;BR /&gt;How can I get the last part, 'filename' or in other words: the part of string behind the last slash character "/" 
&lt;BR /&gt;I looked around on the forum for stringhandling but found only clear descriptions to get the left or right part after the first occurrence of "/". Also found that there exist some stringUtils in exchange but those seem not available in the version I'm using (5.3.0.r101800). Perhaps only for earlier versions. 
&lt;BR /&gt;Best Regards, 
&lt;BR /&gt;Henry</description>
      <pubDate>Tue, 23 Jul 2013 15:41:28 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/resolved-keep-last-part-of-string-after-a-character-or-substring/m-p/2338188#M106449</guid>
      <dc:creator>hvanderborg</dc:creator>
      <dc:date>2013-07-23T15:41:28Z</dc:date>
    </item>
    <item>
      <title>Re: [resolved] keep last part of string after a character (or substring)</title>
      <link>https://community.qlik.com/t5/Talend-Studio/resolved-keep-last-part-of-string-after-a-character-or-substring/m-p/2338189#M106450</link>
      <description>You could use this routine to reverse the string then get the left part then reverse the result.
&lt;BR /&gt;
&lt;BR /&gt; /**
&lt;BR /&gt; * reverseIt() Reverses a string.
&lt;BR /&gt; *
&lt;BR /&gt; * {talendTypes} String
&lt;BR /&gt; *
&lt;BR /&gt; * {Category}my_routines
&lt;BR /&gt; *
&lt;BR /&gt; * {param} string ("fred") input: the string to be reversed
&lt;BR /&gt; *
&lt;BR /&gt; * {example} reverseIt("fred") # derf
&lt;BR /&gt; *
&lt;BR /&gt; */ 
&lt;BR /&gt; public static String reverseIt(String source) {
&lt;BR /&gt; int i, len = source.length();
&lt;BR /&gt; StringBuffer dest = new StringBuffer(len);
&lt;BR /&gt; for (i = (len - 1); i &amp;gt;= 0; i--)
&lt;BR /&gt; dest.append(source.charAt(i));
&lt;BR /&gt; return dest.toString();
&lt;BR /&gt; }</description>
      <pubDate>Tue, 23 Jul 2013 15:51:18 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/resolved-keep-last-part-of-string-after-a-character-or-substring/m-p/2338189#M106450</guid>
      <dc:creator>janhess</dc:creator>
      <dc:date>2013-07-23T15:51:18Z</dc:date>
    </item>
    <item>
      <title>Re: [resolved] keep last part of string after a character (or substring)</title>
      <link>https://community.qlik.com/t5/Talend-Studio/resolved-keep-last-part-of-string-after-a-character-or-substring/m-p/2338190#M106451</link>
      <description>Many thanks for you quick response, that makes sense. Since I'm quite new with Talend, where should I put the code in, a routine? I might need some exact guidance since that would be the first time, so far managed to do all with the built in components</description>
      <pubDate>Tue, 23 Jul 2013 16:12:01 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/resolved-keep-last-part-of-string-after-a-character-or-substring/m-p/2338190#M106451</guid>
      <dc:creator>hvanderborg</dc:creator>
      <dc:date>2013-07-23T16:12:01Z</dc:date>
    </item>
    <item>
      <title>Re: [resolved] keep last part of string after a character (or substring)</title>
      <link>https://community.qlik.com/t5/Talend-Studio/resolved-keep-last-part-of-string-after-a-character-or-substring/m-p/2338191#M106452</link>
      <description>sorry you already said 'use this routine' guess I need to dive into routines then, as simple copy paste of the code in routines gets me syntax error warnings in the routine code screen</description>
      <pubDate>Tue, 23 Jul 2013 16:13:59 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/resolved-keep-last-part-of-string-after-a-character-or-substring/m-p/2338191#M106452</guid>
      <dc:creator>hvanderborg</dc:creator>
      <dc:date>2013-07-23T16:13:59Z</dc:date>
    </item>
    <item>
      <title>Re: [resolved] keep last part of string after a character (or substring)</title>
      <link>https://community.qlik.com/t5/Talend-Studio/resolved-keep-last-part-of-string-after-a-character-or-substring/m-p/2338192#M106453</link>
      <description>create a routine called my_routines and paste the code in to replace what's auto generated for the example routine.
&lt;BR /&gt;This gives
&lt;BR /&gt;package routines;
&lt;BR /&gt;/*
&lt;BR /&gt; * user specification: the function's comment should contain keys as follows: 1. write about the function's comment.but
&lt;BR /&gt; * it must be before the "{talendTypes}" key.
&lt;BR /&gt; * 
&lt;BR /&gt; * 2. {talendTypes} 's value must be talend Type, it is required . its value should be one of: String, char | Character,
&lt;BR /&gt; * long | Long, int | Integer, boolean | Boolean, byte | Byte, Date, double | Double, float | Float, Object, short |
&lt;BR /&gt; * Short
&lt;BR /&gt; * 
&lt;BR /&gt; * 3. {Category} define a category for the Function. it is required. its value is user-defined .
&lt;BR /&gt; * 
&lt;BR /&gt; * 4. {param} 's format is: {param} &amp;lt;type&amp;gt; &amp;lt;name&amp;gt;
&lt;BR /&gt; * 
&lt;BR /&gt; * &amp;lt;type&amp;gt; 's value should be one of: string, int, list, double, object, boolean, long, char, date. &amp;lt;name&amp;gt;'s value is the
&lt;BR /&gt; * Function's parameter name. the {param} is optional. so if you the Function without the parameters. the {param} don't
&lt;BR /&gt; * added. you can have many parameters for the Function.
&lt;BR /&gt; * 
&lt;BR /&gt; * 5. {example} gives a example for the Function. it is optional.
&lt;BR /&gt; */
&lt;BR /&gt;public class my_routines {
&lt;BR /&gt; /**
&lt;BR /&gt; * reverseIt() Reverses a string.
&lt;BR /&gt; *
&lt;BR /&gt; * {talendTypes} String
&lt;BR /&gt; *
&lt;BR /&gt; * {Category}my_routines
&lt;BR /&gt; *
&lt;BR /&gt; * {param} string ("fred") input: the string to be reversed
&lt;BR /&gt; *
&lt;BR /&gt; * {example} reverseIt("fred") # derf
&lt;BR /&gt; *
&lt;BR /&gt; */
&lt;BR /&gt; public static String reverseIt(String source) {
&lt;BR /&gt; int i, len = source.length();
&lt;BR /&gt; StringBuffer dest = new StringBuffer(len);
&lt;BR /&gt; for (i = (len - 1); i &amp;gt;= 0; i--)
&lt;BR /&gt; dest.append(source.charAt(i));
&lt;BR /&gt; return dest.toString();
&lt;BR /&gt; }
&lt;BR /&gt;}</description>
      <pubDate>Tue, 23 Jul 2013 16:54:55 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/resolved-keep-last-part-of-string-after-a-character-or-substring/m-p/2338192#M106453</guid>
      <dc:creator>janhess</dc:creator>
      <dc:date>2013-07-23T16:54:55Z</dc:date>
    </item>
    <item>
      <title>Re: [resolved] keep last part of string after a character (or substring)</title>
      <link>https://community.qlik.com/t5/Talend-Studio/resolved-keep-last-part-of-string-after-a-character-or-substring/m-p/2338193#M106454</link>
      <description>Thank you so much Janhess, 
&lt;BR /&gt;I missed the 'public class my_routines {' part in my first try, discovered the mistake thanks to your example. 
&lt;BR /&gt;If others also stumble on this thread, I used the routine by adding the expression below in tMap. 
&lt;BR /&gt;my_routines.reverseIt(StringHandling.LEFT((my_routines.reverseIt(row8.imageUrl)),StringHandling.INDEX((my_routines.reverseIt(row8.imageUrl)) ,"/"))) 
&lt;BR /&gt;Perhaps the expression can be made easier I don't know, but the end result is exactly the last part after the "/", as intended. 
&lt;BR /&gt;Many thanks, how should I indicate as resolved? 
&lt;BR /&gt;Henry</description>
      <pubDate>Tue, 23 Jul 2013 17:23:07 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/resolved-keep-last-part-of-string-after-a-character-or-substring/m-p/2338193#M106454</guid>
      <dc:creator>hvanderborg</dc:creator>
      <dc:date>2013-07-23T17:23:07Z</dc:date>
    </item>
    <item>
      <title>Re: [resolved] keep last part of string after a character (or substring)</title>
      <link>https://community.qlik.com/t5/Talend-Studio/resolved-keep-last-part-of-string-after-a-character-or-substring/m-p/2338194#M106455</link>
      <description>Hello guy,&lt;BR /&gt;what if I have a column with URL"s like:&lt;BR /&gt;&lt;A href="http://www.mydomain-1.com/a/b/c/image1.jpg" rel="nofollow noopener noreferrer"&gt;http://www.mydomain-1.com/a/b/c/image1.jpg&lt;/A&gt;&lt;BR /&gt;&lt;A href="http://www.mydomain-2.com/j/u/image2.jpg" rel="nofollow noopener noreferrer"&gt;http://www.mydomain-2.com/j/u/image2.jpg&lt;/A&gt;&lt;BR /&gt;.....&lt;BR /&gt;&lt;A href="http://www.mydomain-x.com/f/r/y/w/image20000.jpg" rel="nofollow noopener noreferrer"&gt;http://www.mydomain-x.com/f/r/y/w/image20000.jpg&lt;/A&gt;&lt;BR /&gt;The ulrs have not the same lenght, domains and subfolders.&lt;BR /&gt;How can I substract only the base name of the image, like:&lt;BR /&gt;image1.jpg&lt;BR /&gt;image2.jpg&lt;BR /&gt;...&lt;BR /&gt;image20000.jpg&lt;BR /&gt;Thank you for your help,&lt;BR /&gt;Lucian</description>
      <pubDate>Sun, 06 Apr 2014 07:39:12 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/resolved-keep-last-part-of-string-after-a-character-or-substring/m-p/2338194#M106455</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2014-04-06T07:39:12Z</dc:date>
    </item>
    <item>
      <title>Re: [resolved] keep last part of string after a character (or substring)</title>
      <link>https://community.qlik.com/t5/Talend-Studio/resolved-keep-last-part-of-string-after-a-character-or-substring/m-p/2338195#M106456</link>
      <description>Don't forget that the String Class has the method String.lastIndexOf, so you could simply use this with String.substring.</description>
      <pubDate>Sun, 06 Apr 2014 13:45:48 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/resolved-keep-last-part-of-string-after-a-character-or-substring/m-p/2338195#M106456</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2014-04-06T13:45:48Z</dc:date>
    </item>
    <item>
      <title>Re: [resolved] keep last part of string after a character (or substring)</title>
      <link>https://community.qlik.com/t5/Talend-Studio/resolved-keep-last-part-of-string-after-a-character-or-substring/m-p/2338196#M106457</link>
      <description>Hi, &lt;BR /&gt;You're obliged to create your function and add it to your talend studio, in repository&amp;gt;code&amp;gt;routine&lt;BR /&gt;&lt;BR /&gt;When your fonction added you will find it in tMap in the category "defined by user". &lt;BR /&gt;    &lt;BR /&gt;This is a simple function in java that i have made on Eclipse, i have tested on two exemple and  i have the right result that you are looking for. &lt;BR /&gt;         &lt;BR /&gt;String Str = new String("http://www.mydomain-1.com/a/b/c/image1.jpg");&lt;BR /&gt;          &lt;BR /&gt;          System.out.print("Found Index :" );&lt;BR /&gt;          System.out.println(Str.lastIndexOf("/"));&lt;BR /&gt;          int beginIndex = Str.lastIndexOf("/")+1; &lt;BR /&gt;          &lt;BR /&gt;          Str = Str.substring(beginIndex); &lt;BR /&gt;          System.out.println(Str);     &lt;BR /&gt;          &lt;BR /&gt;          String Str1 = new String("http://www.mydomain-x.com/f/r/y/w/image20000.jpg");&lt;BR /&gt;          &lt;BR /&gt;          System.out.print("Found Index :" );&lt;BR /&gt;          System.out.println(Str1.lastIndexOf("/"));&lt;BR /&gt;          int beginIndex1 = Str1.lastIndexOf("/")+1; &lt;BR /&gt;          &lt;BR /&gt;          Str1 = Str1.substring(beginIndex1); &lt;BR /&gt;          System.out.println(Str1);&lt;BR /&gt;results : &lt;BR /&gt;Found Index :31&lt;BR /&gt;image1.jpg&lt;BR /&gt;Found Index :33&lt;BR /&gt;image20000.jpg  &lt;BR /&gt;   &lt;BR /&gt;in your class you can use this function. &lt;BR /&gt; &lt;BR /&gt;public static String deleateSuboldersFromUrl(String str) {&lt;BR /&gt;		&lt;BR /&gt;    	return str.substring(str.lastIndexOf("/")+1);&lt;BR /&gt;        &lt;BR /&gt;    }&lt;BR /&gt;It is an idea and you can adapt and optimize it.&lt;BR /&gt;Best regards</description>
      <pubDate>Sun, 06 Apr 2014 15:09:02 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/resolved-keep-last-part-of-string-after-a-character-or-substring/m-p/2338196#M106457</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2014-04-06T15:09:02Z</dc:date>
    </item>
  </channel>
</rss>

