<?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: Search For Strings Using Partial String in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/Search-For-Strings-Using-Partial-String/m-p/19924#M18168</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Sounds like an explicit loop will be easier and more clear.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;for( icol = 1, icol &amp;lt;= nitems(colnames), icol++,&lt;/P&gt;&lt;P&gt; // use regex on char(colnames&lt;I&gt;) and break out of this loop when you get the match you need.&lt;/I&gt;&lt;/P&gt;&lt;P&gt;)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Since the column names DO have commas, and you need the icol index, and the regex can be a lot simpler.&amp;nbsp; This isn't tested, but something like&lt;/P&gt;&lt;P&gt;if( ! ismissing( regex( char(colnames[ icol ]), "ID" ) ), break() );&lt;/P&gt;&lt;P&gt;would test each icol for ID in the name.&amp;nbsp; regex returns missing if the match fails.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 15 Aug 2016 20:16:36 GMT</pubDate>
    <dc:creator>Craige_Hales</dc:creator>
    <dc:date>2016-08-15T20:16:36Z</dc:date>
    <item>
      <title>Search For Strings Using Partial String</title>
      <link>https://community.jmp.com/t5/Discussions/Search-For-Strings-Using-Partial-String/m-p/19921#M18165</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;All, &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; I am trying to search for string matches with partial&amp;nbsp; string as the search criteria . I have tried multiple ways as I show below - I believe there must be a better way using RegEx or Pat Match to do this - but I am unable to get it right. Any help will be appreciated . &lt;/P&gt;&lt;P&gt;&lt;BR /&gt;For the Sake of an example , I am using Air Traffic Sample Data table : &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;// Method # 1 Using Pat Match &lt;/P&gt;&lt;P&gt;dt&amp;nbsp; = Current Data Table(); &lt;/P&gt;&lt;P&gt;ColNames = dt &amp;lt;&amp;lt; Get COlumn Names(); &lt;/P&gt;&lt;P&gt;Match = list(); &lt;/P&gt;&lt;P&gt;sp = Pat Span("ID"); &lt;/P&gt;&lt;P&gt;Pat Match(ColNames,sp&amp;gt;&amp;gt;Match);&lt;/P&gt;&lt;P&gt;Match;&amp;nbsp; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;// This yields no matches . However in the same code - if ID itself was a column name - this works . So I want to understand how to use part of the search string to do the search . &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;// Method # 2 Using Contains() &lt;/P&gt;&lt;P&gt;for(&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; i=1, i&amp;lt;= N Items(ColNames),i++,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; If(Contains(ColNames&lt;I&gt;,"ID")== 1,&lt;/I&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Insert Into(Match,i);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; );&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; );&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Best &lt;BR /&gt;uday &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 15 Aug 2016 17:13:40 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Search-For-Strings-Using-Partial-String/m-p/19921#M18165</guid>
      <dc:creator>uday_guntupalli</dc:creator>
      <dc:date>2016-08-15T17:13:40Z</dc:date>
    </item>
    <item>
      <title>Re: Search For Strings Using Partial String</title>
      <link>https://community.jmp.com/t5/Discussions/Search-For-Strings-Using-Partial-String/m-p/19922#M18166</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;maybe like this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier; font-size: 8pt;"&gt;dt&amp;nbsp; = Current Data Table();&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier; font-size: 8pt;"&gt;ColNames = dt &amp;lt;&amp;lt; Get COlumn Names();&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier; font-size: 8pt;"&gt;colstrings = &lt;STRONG style=": ; font-size: 12pt;"&gt;char&lt;/STRONG&gt;(colnames);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier; font-size: 8pt;"&gt;match = regex(colstrings, "[{,]\s*([^{,}]*ID[^{,}]*)[,}]", "\1");&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 8pt; font-family: 'courier new', courier;"&gt;show(Match);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Match = "Flight ID";&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;which depends on the column names not using commas or curly braces.&amp;nbsp; The char function turns the list of names into a string:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;{Airline, Carrier Code, Flight Number, Tail Number, Flight ID, Event, Airport, Time,&lt;/P&gt;&lt;P&gt;Original Time, Longitude, Latitude}&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;becomes&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;"{Airline, Carrier Code, Flight Number, Tail Number, Flight ID, Event, Airport, Time, Original Time, Longitude, Latitude}"&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I chose regex for this because...well it won't be beautiful either way.&amp;nbsp; Breaking down the regex pattern:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;"[{,]&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; either an open curly brace or a comma&lt;/P&gt;&lt;P&gt;\s*&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; optional white space&lt;/P&gt;&lt;P&gt;([^{,}]*ID[^{,}]*)&amp;nbsp;&amp;nbsp;&amp;nbsp; the outer parens are the \1 match (more below)&lt;/P&gt;&lt;P&gt;[,}]"&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; either a comma or a close curly brace&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;breaking down the \1 part:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333px;"&gt;[^{,}]*&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; zero or more characters that are not curly braces or commas&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333px;"&gt;ID&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; the word you are hunting in a column name&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333px;"&gt;[^{,}]*&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="font-size: 13.3333px;"&gt;zero or more characters that are not curly braces or commas&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333px;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333px;"&gt;the third arg to regex, "\1", means use the first open paren to identify the replacement text.&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 15 Aug 2016 18:11:08 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Search-For-Strings-Using-Partial-String/m-p/19922#M18166</guid>
      <dc:creator>Craige_Hales</dc:creator>
      <dc:date>2016-08-15T18:11:08Z</dc:date>
    </item>
    <item>
      <title>Re: Search For Strings Using Partial String</title>
      <link>https://community.jmp.com/t5/Discussions/Search-For-Strings-Using-Partial-String/m-p/19923#M18167</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;A href="https://community.jmp.com/people/Craige@JMP"&gt;Craige@JMP&lt;/A&gt;​ : &lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; While the solution you provided works - if I may I have 2 follow up questions : &lt;/P&gt;&lt;P&gt;1. How would you get the indices when there are matches found ? &lt;/P&gt;&lt;P&gt;2. If the column names look like this - which they do in my case &lt;/P&gt;&lt;P&gt;Name( "IPhone 7, California, Yes" )&amp;nbsp; - ColNames&lt;BR /&gt;Name(\!"&lt;SPAN style="font-size: 13.3333px;"&gt;IPhone 7&lt;/SPAN&gt;, &lt;SPAN style="font-size: 13.3333px;"&gt;California&lt;/SPAN&gt;, &lt;SPAN style="font-size: 13.3333px;"&gt;Yes&lt;/SPAN&gt;\!") - ColString &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Please advice . &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Best &lt;/P&gt;&lt;P&gt;Uday &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 15 Aug 2016 19:09:17 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Search-For-Strings-Using-Partial-String/m-p/19923#M18167</guid>
      <dc:creator>uday_guntupalli</dc:creator>
      <dc:date>2016-08-15T19:09:17Z</dc:date>
    </item>
    <item>
      <title>Re: Search For Strings Using Partial String</title>
      <link>https://community.jmp.com/t5/Discussions/Search-For-Strings-Using-Partial-String/m-p/19924#M18168</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Sounds like an explicit loop will be easier and more clear.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;for( icol = 1, icol &amp;lt;= nitems(colnames), icol++,&lt;/P&gt;&lt;P&gt; // use regex on char(colnames&lt;I&gt;) and break out of this loop when you get the match you need.&lt;/I&gt;&lt;/P&gt;&lt;P&gt;)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Since the column names DO have commas, and you need the icol index, and the regex can be a lot simpler.&amp;nbsp; This isn't tested, but something like&lt;/P&gt;&lt;P&gt;if( ! ismissing( regex( char(colnames[ icol ]), "ID" ) ), break() );&lt;/P&gt;&lt;P&gt;would test each icol for ID in the name.&amp;nbsp; regex returns missing if the match fails.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 15 Aug 2016 20:16:36 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Search-For-Strings-Using-Partial-String/m-p/19924#M18168</guid>
      <dc:creator>Craige_Hales</dc:creator>
      <dc:date>2016-08-15T20:16:36Z</dc:date>
    </item>
  </channel>
</rss>

