<?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: Country Code search in text string in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/Country-Code-search-in-text-string/m-p/1757880#M590675</link>
    <description>&lt;P&gt;Unfortunately this would be an extra problem. The country code is not always at the end.&lt;BR /&gt;For example:&lt;BR /&gt;&lt;SPAN&gt;'Project C: Simon says dance in NL (if you want)'&lt;/SPAN&gt;&lt;/P&gt;</description>
    <pubDate>Mon, 02 Nov 2020 16:01:52 GMT</pubDate>
    <dc:creator>MauriceBruns2019</dc:creator>
    <dc:date>2020-11-02T16:01:52Z</dc:date>
    <item>
      <title>Country Code search in text string</title>
      <link>https://community.qlik.com/t5/QlikView/Country-Code-search-in-text-string/m-p/1757857#M590673</link>
      <description>&lt;P&gt;Hello everyone,&lt;/P&gt;&lt;P&gt;I am trying to figure out a way to identify a country code within a string. The string that is loaded is a variable length string and within that string it 'could' contain a country code.&lt;/P&gt;&lt;P&gt;The goal is to check if a specific country code exists in a text; then i would compare this with a specific country code field.&lt;/P&gt;&lt;P&gt;For example:&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;&lt;STRONG&gt;Project Name&lt;/STRONG&gt;&lt;/TD&gt;&lt;TD&gt;&lt;STRONG&gt;Text Country&lt;/STRONG&gt;&lt;/TD&gt;&lt;TD&gt;&lt;STRONG&gt;Impacted Country&lt;/STRONG&gt;&lt;/TD&gt;&lt;TD&gt;&lt;STRONG&gt;Outcome&lt;/STRONG&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Project A: Simon says jump - NL&lt;/TD&gt;&lt;TD&gt;NL&lt;/TD&gt;&lt;TD&gt;NL&lt;/TD&gt;&lt;TD&gt;TRUE&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Project B: Simon says sing - UK&lt;/TD&gt;&lt;TD&gt;UK&lt;/TD&gt;&lt;TD&gt;NL&lt;/TD&gt;&lt;TD&gt;FALSE&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&lt;BR /&gt;Some of the problems that i have:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;&lt;SPAN&gt;The Project Name text is not consistent in terms of structure&lt;/SPAN&gt;&lt;/LI&gt;&lt;LI&gt;&lt;SPAN&gt;The text might include a dash, then the code:&amp;nbsp; 'Simon says jump - NL'; and sometimes not 'Simon says jump NL'&lt;/SPAN&gt;&lt;/LI&gt;&lt;LI&gt;&lt;SPAN&gt;Often the text does not contain a country code, and&lt;/SPAN&gt;&lt;/LI&gt;&lt;LI&gt;&lt;SPAN&gt;Perhaps the search might pick up the 'ro' from the text 'Project', and present RO [Romania] as my Text Country result.&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;Any ideas anyone?&lt;/P&gt;&lt;P&gt;Maurice&lt;/P&gt;</description>
      <pubDate>Sat, 16 Nov 2024 17:53:24 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Country-Code-search-in-text-string/m-p/1757857#M590673</guid>
      <dc:creator>MauriceBruns2019</dc:creator>
      <dc:date>2024-11-16T17:53:24Z</dc:date>
    </item>
    <item>
      <title>Re: Country Code search in text string</title>
      <link>https://community.qlik.com/t5/QlikView/Country-Code-search-in-text-string/m-p/1757872#M590674</link>
      <description>&lt;P&gt;does the country code always come at the end? also is the length always 2?&lt;/P&gt;&lt;P&gt;if so why not get the last 2 characters from your string and compare using that&lt;/P&gt;</description>
      <pubDate>Mon, 02 Nov 2020 15:52:10 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Country-Code-search-in-text-string/m-p/1757872#M590674</guid>
      <dc:creator>dplr-rn</dc:creator>
      <dc:date>2020-11-02T15:52:10Z</dc:date>
    </item>
    <item>
      <title>Re: Country Code search in text string</title>
      <link>https://community.qlik.com/t5/QlikView/Country-Code-search-in-text-string/m-p/1757880#M590675</link>
      <description>&lt;P&gt;Unfortunately this would be an extra problem. The country code is not always at the end.&lt;BR /&gt;For example:&lt;BR /&gt;&lt;SPAN&gt;'Project C: Simon says dance in NL (if you want)'&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 02 Nov 2020 16:01:52 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Country-Code-search-in-text-string/m-p/1757880#M590675</guid>
      <dc:creator>MauriceBruns2019</dc:creator>
      <dc:date>2020-11-02T16:01:52Z</dc:date>
    </item>
    <item>
      <title>Re: Country Code search in text string</title>
      <link>https://community.qlik.com/t5/QlikView/Country-Code-search-in-text-string/m-p/1757949#M590676</link>
      <description>&lt;P&gt;The easiest you can do is a JScript macro, where you can use a regular expression (VB doesn't known regular expressions).&lt;/P&gt;&lt;P&gt;In the macro editor it looks like this:&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;var regExp;

function InitRegExp(codes){
	regExp=new RegExp("(\\s|-)("+codes+")(\\s|-|\$)");
	return 0;
}

function GetCountryCode(text){
	var res=regExp.exec(text);
	return res ? res[2] : "";
}&lt;/LI-CODE&gt;&lt;P&gt;And the script for example:&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;Countries:
LOAD * INLINE [
Code
NL
RO
US
EN
];

t:
LOAD
InitRegExp(Concat(DISTINCT Code,'|')) as InitRegExp
Resident Countries;

drop table t;

Projects:
LOAD *,
GetCountryCode(Project) as Country 
INLINE [
Project
Project A: Simon says jump - NL
Project A: Simon says jump -RO
Project A: Simon says jump -Ro NL
Project A: Simon says jump US
US Project A: Simon says jump -EN- 
Project A: Simon NL says jump
Project A: SimonNL says jump
Project A: Simon NLsays jump
Project A: Simon -US- says jump
Project A: Simon -EN says jump   
];&lt;/LI-CODE&gt;&lt;P&gt;In the example the regular expression is build from "(\\s|-)(NL|US|EN|RO)(\\s|-|\$)".&lt;/P&gt;&lt;P&gt;This means it consists of three groups:&lt;BR /&gt;1. "(\\s|-)" the start of search string, can be a whitespace or "-" (it cannot be at the beginning of the text that is being searched for matches)&lt;BR /&gt;2. followed by "(NL|US|EN|RO)" one of the country code&lt;BR /&gt;3. followed by "(\\s|-|\$)" the end of searchs tring, can be a whitespace, a "-" or it can be at the end of the text.&lt;/P&gt;&lt;P&gt;Because of the three groups, the result of exec() is an array with 4 elements. The first is the whole match string, the others are the results for each group. So the function return only the result for the second group.&lt;/P&gt;&lt;P&gt;The regulare expression is case sensitive! It only searches for country codes in capital letters.&lt;/P&gt;</description>
      <pubDate>Mon, 02 Nov 2020 20:47:00 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Country-Code-search-in-text-string/m-p/1757949#M590676</guid>
      <dc:creator>cwolf</dc:creator>
      <dc:date>2020-11-02T20:47:00Z</dc:date>
    </item>
  </channel>
</rss>

