<?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: Regex to match repeated letters in string using java pattern in Talend Studio</title>
    <link>https://community.qlik.com/t5/Talend-Studio/Regex-to-match-repeated-letters-in-string-using-java-pattern/m-p/2217321#M12958</link>
    <description>Final solution is this - added a custom routine which I call in the tMap&lt;BR /&gt;package routines;&lt;BR /&gt;public class FT_CompareString {&lt;BR /&gt;&lt;BR /&gt;    public static String CheckString(String input) {&lt;BR /&gt;    	&lt;BR /&gt;    	if (input != null &amp;amp;&amp;amp; input != "" &amp;amp;&amp;amp; input.replace(" ", "").split(input.replace(" ", "").substring(0,1)).length &amp;gt;0){&lt;BR /&gt;    		return input;&lt;BR /&gt;    	}&lt;BR /&gt;    	else{&lt;BR /&gt;    		return null;&lt;BR /&gt;    	}&lt;BR /&gt;    &lt;BR /&gt;    	&lt;BR /&gt;    }&lt;BR /&gt;}</description>
    <pubDate>Fri, 05 Oct 2012 16:45:33 GMT</pubDate>
    <dc:creator>agentgill</dc:creator>
    <dc:date>2012-10-05T16:45:33Z</dc:date>
    <item>
      <title>Regex to match repeated letters in string using java pattern</title>
      <link>https://community.qlik.com/t5/Talend-Studio/Regex-to-match-repeated-letters-in-string-using-java-pattern/m-p/2217317#M12954</link>
      <description>Talend version: 4.2.3 / 5.2.0M3 
&lt;BR /&gt;OS: Windows / Mac 
&lt;BR /&gt;I am trying to parse out phone numbers which have repeating characters e.g. 
&lt;BR /&gt;0000, 111111, 99999999, 8888, 22222, 000000000 - basically anything which is repeat 
&lt;BR /&gt;I am using the following RegEx in the tMap 
&lt;BR /&gt;row1.Phone.matches("()\1{3}")?"":row1.Phone 
&lt;BR /&gt;or this 
&lt;BR /&gt;row1.Phone.matches("()\\1{3}")?"":row1.Phone (parse out forward slash for java.... 
&lt;BR /&gt;When testing the expression I get this 
&lt;BR /&gt;Exception in thread "Main" java.lang.error : Unresolved compilation errors 
&lt;BR /&gt;This works outside Talend - see 2nd SS. 
&lt;BR /&gt;Any ideas?</description>
      <pubDate>Fri, 05 Oct 2012 11:55:20 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/Regex-to-match-repeated-letters-in-string-using-java-pattern/m-p/2217317#M12954</guid>
      <dc:creator>agentgill</dc:creator>
      <dc:date>2012-10-05T11:55:20Z</dc:date>
    </item>
    <item>
      <title>Re: Regex to match repeated letters in string using java pattern</title>
      <link>https://community.qlik.com/t5/Talend-Studio/Regex-to-match-repeated-letters-in-string-using-java-pattern/m-p/2217318#M12955</link>
      <description>Actually, a job is generated behind the scene to handle this record.
&lt;BR /&gt;As your value to test is not quoted, the generated job contains expression like &amp;lt;b&amp;gt;123.matches(...)&amp;lt;/b&amp;gt; which does not fullfil the java syntax
&lt;BR /&gt;You can try to replace all the occurences of &amp;lt;row1.Phone&amp;gt; by &amp;lt;String.valueOf(row1.Phone)&amp;gt; or even &amp;lt;row1.Phone+""&amp;gt; to avoid compilation problems.
&lt;BR /&gt;Although this compile problem does not appear if you run the job. it is a bit weird in the test area from the point of view of users.
&lt;BR /&gt;Another thing is that the method "string.matches(regex)" will only filter the records like "1111" "2222", but not "12222" or "22221". Same results with "Pattern.matches(regex, string)".
&lt;BR /&gt;So I propose to use the following expression to filter the inputs containing repetition inside:
&lt;BR /&gt;java.util.regex.Pattern.compile("()\\1{3}").matcher(String.valueOf(row1.Phone)+"").find() ? "" : String.valueOf(row1.Phone)
&lt;BR /&gt;This can work in the test area too since I added "String.valueOf"</description>
      <pubDate>Fri, 05 Oct 2012 14:05:39 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/Regex-to-match-repeated-letters-in-string-using-java-pattern/m-p/2217318#M12955</guid>
      <dc:creator>sizhaoliu</dc:creator>
      <dc:date>2012-10-05T14:05:39Z</dc:date>
    </item>
    <item>
      <title>Re: Regex to match repeated letters in string using java pattern</title>
      <link>https://community.qlik.com/t5/Talend-Studio/Regex-to-match-repeated-letters-in-string-using-java-pattern/m-p/2217319#M12956</link>
      <description>Thanks, no more compilation errors. I see now, very powerful. It's possible to call external Java classes! 
&lt;BR /&gt;Very close now, but not sure all the use cases are covered. 
&lt;BR /&gt;A phone number like this results in null 
&lt;BR /&gt;0800 2222 1234 
&lt;BR /&gt;It's beginning to look like RegEx is not the best answer. What do you think / recommend? 
&lt;BR /&gt;Thanks</description>
      <pubDate>Fri, 05 Oct 2012 15:14:08 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/Regex-to-match-repeated-letters-in-string-using-java-pattern/m-p/2217319#M12956</guid>
      <dc:creator>agentgill</dc:creator>
      <dc:date>2012-10-05T15:14:08Z</dc:date>
    </item>
    <item>
      <title>Re: Regex to match repeated letters in string using java pattern</title>
      <link>https://community.qlik.com/t5/Talend-Studio/Regex-to-match-repeated-letters-in-string-using-java-pattern/m-p/2217320#M12957</link>
      <description>I'm thinking a custom Routine. Get the first char and string length, then compare with original string</description>
      <pubDate>Fri, 05 Oct 2012 15:49:16 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/Regex-to-match-repeated-letters-in-string-using-java-pattern/m-p/2217320#M12957</guid>
      <dc:creator>agentgill</dc:creator>
      <dc:date>2012-10-05T15:49:16Z</dc:date>
    </item>
    <item>
      <title>Re: Regex to match repeated letters in string using java pattern</title>
      <link>https://community.qlik.com/t5/Talend-Studio/Regex-to-match-repeated-letters-in-string-using-java-pattern/m-p/2217321#M12958</link>
      <description>Final solution is this - added a custom routine which I call in the tMap&lt;BR /&gt;package routines;&lt;BR /&gt;public class FT_CompareString {&lt;BR /&gt;&lt;BR /&gt;    public static String CheckString(String input) {&lt;BR /&gt;    	&lt;BR /&gt;    	if (input != null &amp;amp;&amp;amp; input != "" &amp;amp;&amp;amp; input.replace(" ", "").split(input.replace(" ", "").substring(0,1)).length &amp;gt;0){&lt;BR /&gt;    		return input;&lt;BR /&gt;    	}&lt;BR /&gt;    	else{&lt;BR /&gt;    		return null;&lt;BR /&gt;    	}&lt;BR /&gt;    &lt;BR /&gt;    	&lt;BR /&gt;    }&lt;BR /&gt;}</description>
      <pubDate>Fri, 05 Oct 2012 16:45:33 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/Regex-to-match-repeated-letters-in-string-using-java-pattern/m-p/2217321#M12958</guid>
      <dc:creator>agentgill</dc:creator>
      <dc:date>2012-10-05T16:45:33Z</dc:date>
    </item>
  </channel>
</rss>

