<?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: How to extract the position of a char in a string? in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/How-to-extract-the-position-of-a-char-in-a-string/m-p/450725#M69758</link>
    <description>&lt;P&gt;Expanding on&amp;nbsp;&lt;a href="https://community.jmp.com/t5/user/viewprofilepage/user-id/14366"&gt;@jthi&lt;/a&gt;&amp;nbsp;great solution, I believe the best way to handle your issue is to create a new column to place the results in.&amp;nbsp; Also, you indicated that not just a "." might be used as a special character.&amp;nbsp; So the JSL below is a formula that can handle multiple special characters, and also returns the results in a new column.&amp;nbsp; Just create a character column and cut and past the formula into it.&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="txnelson_0-1641971637056.png" style="width: 554px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/38927i08FDF745CD934702/image-dimensions/554x296?v=v2" width="554" height="296" role="button" title="txnelson_0-1641971637056.png" alt="txnelson_0-1641971637056.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;list_of_chars = Words( :strings, "" );
Substitute Into( list_of_chars, ".", "", "+", "", "/", "" );
charList = As List( Loc Nonmissing( list_of_chars ) );
Substr( Char( charList ), 2, Length( Char( charList ) ) - 2 );&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 12 Jan 2022 07:15:09 GMT</pubDate>
    <dc:creator>txnelson</dc:creator>
    <dc:date>2022-01-12T07:15:09Z</dc:date>
    <item>
      <title>How to extract the position of a char in a string?</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-extract-the-position-of-a-char-in-a-string/m-p/450677#M69753</link>
      <description>&lt;P&gt;I have the following column, which contains string of char, such as dot or char (no number and special char).&lt;/P&gt;&lt;P&gt;I want to generate a column that list out the position of the char which is not a dot. See an example below.&lt;/P&gt;&lt;P&gt;Is there any formula or script I can use in JMP??&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;·cgaagt··a···········&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;2,3,4,5,6,7,10&lt;BR /&gt;··t·a·············c··&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 3,5,19&lt;BR /&gt;·····················&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 10 Jun 2023 23:42:25 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-extract-the-position-of-a-char-in-a-string/m-p/450677#M69753</guid>
      <dc:creator>JMP2021</dc:creator>
      <dc:date>2023-06-10T23:42:25Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract the position of a char in a string?</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-extract-the-position-of-a-char-in-a-string/m-p/450698#M69756</link>
      <description>&lt;P&gt;I think you will have to script it.&amp;nbsp;&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;Convert the string to a list with &lt;EM&gt;Words(str, "")&lt;/EM&gt;&lt;/LI&gt;&lt;LI&gt;Replace all values you aren't interested in with empty string (missing value) by using Substitute&lt;/LI&gt;&lt;LI&gt;Use Loc NonMissing to find indices of non missing values&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here(1);

a = "·cgaagt··a···········";
b = "··t·a·············c··";
c = "·····················";
list_of_chars = Words(a, "");
Substitute Into(list_of_chars, "·", "");
Show(AsList(Loc Nonmissing(list_of_chars)));

a = "··t·a·············c··";
list_of_chars = Words(a, "");
Substitute Into(list_of_chars, "·", "");
Show(AsList(Loc Nonmissing(list_of_chars)));

a = "·····················";
list_of_chars = Words(a, "");
Substitute Into(list_of_chars, "·", "");
Show(AsList(Loc Nonmissing(list_of_chars)));

//As List(Loc Nonmissing(list_of_chars)) = {2, 3, 4, 5, 6, 7, 10};
//As List(Loc Nonmissing(list_of_chars)) = {3, 5, 19};
//As List(Loc Nonmissing(list_of_chars)) = {};&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 12 Jan 2022 05:36:47 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-extract-the-position-of-a-char-in-a-string/m-p/450698#M69756</guid>
      <dc:creator>jthi</dc:creator>
      <dc:date>2022-01-12T05:36:47Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract the position of a char in a string?</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-extract-the-position-of-a-char-in-a-string/m-p/450725#M69758</link>
      <description>&lt;P&gt;Expanding on&amp;nbsp;&lt;a href="https://community.jmp.com/t5/user/viewprofilepage/user-id/14366"&gt;@jthi&lt;/a&gt;&amp;nbsp;great solution, I believe the best way to handle your issue is to create a new column to place the results in.&amp;nbsp; Also, you indicated that not just a "." might be used as a special character.&amp;nbsp; So the JSL below is a formula that can handle multiple special characters, and also returns the results in a new column.&amp;nbsp; Just create a character column and cut and past the formula into it.&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="txnelson_0-1641971637056.png" style="width: 554px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/38927i08FDF745CD934702/image-dimensions/554x296?v=v2" width="554" height="296" role="button" title="txnelson_0-1641971637056.png" alt="txnelson_0-1641971637056.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;list_of_chars = Words( :strings, "" );
Substitute Into( list_of_chars, ".", "", "+", "", "/", "" );
charList = As List( Loc Nonmissing( list_of_chars ) );
Substr( Char( charList ), 2, Length( Char( charList ) ) - 2 );&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 12 Jan 2022 07:15:09 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-extract-the-position-of-a-char-in-a-string/m-p/450725#M69758</guid>
      <dc:creator>txnelson</dc:creator>
      <dc:date>2022-01-12T07:15:09Z</dc:date>
    </item>
  </channel>
</rss>

