<?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 make Uppercase, Regex and Contain function efficient? in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/How-to-make-Uppercase-Regex-and-Contain-function-efficient/m-p/933609#M108983</link>
    <description>&lt;P&gt;What is the script supposed to do?&lt;/P&gt;</description>
    <pubDate>Tue, 03 Mar 2026 14:34:20 GMT</pubDate>
    <dc:creator>jthi</dc:creator>
    <dc:date>2026-03-03T14:34:20Z</dc:date>
    <item>
      <title>How to make Uppercase, Regex and Contain function efficient?</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-make-Uppercase-Regex-and-Contain-function-efficient/m-p/933595#M108982</link>
      <description>&lt;P&gt;I have a script to that takes user input and scanned through the entire table and tag the user input in the new column. I have tables with &amp;gt;10M rows and this script is taking few minutes. How can I make it faster? Thanks in advance.&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;
// Capture the start time
start_time = Tick Seconds();

// --- Setup &amp;amp; guards ---
dt = Current Data Table();
If( Is Empty( dt ), Throw( "No active data table." ));

colNames = dt &amp;lt;&amp;lt; Get Column Names("String");
Case sensitive = 0;

// Open a dialog to select exactly one column
nw = New Window("User Inputs",
    &amp;lt;&amp;lt;Modal,
    &amp;lt;&amp;lt;Return Result,
    V List Box(
        Text Box("Select Column:"),
        colDropdown = Combo Box(colNames),
   		Spacer Box(Size(0, 10)),
   		
   		CasesensitiveCB = Check Box("Case sensitive", 0), 
        Spacer Box(Size(0, 5)),
    
        Text Box("Enter the List "),
        variablebox = Text Edit Box("", &amp;lt;&amp;lt;Set N Lines(30), &amp;lt;&amp;lt;Set Width(180)),
        
        Spacer Box(Size(0, 10)),
        Button Box("OK",
			selectedCol = colDropdown &amp;lt;&amp;lt; Get Selected;
			Case sensitive   = CasesensitiveCB &amp;lt;&amp;lt; Get;),
        Button Box("Cancel")
    )
);

If( nw["Button"] != 1, Stop(); );

unique = Collapse Whitespace(nw["variablebox"]);
unique = Substitute(unique, ";", ",");

// 1. Process userentry: Uppercase if needed, then remove leading zeros from each word
wordList = Words(unique, ", ");
If( Case sensitive == 0, wordList = Words(Uppercase(unique), ", ") );

For( i = 1, i &amp;lt;= N Items( wordList ), i++,
	wordList[i] = Regex( wordList[i], "^0*", "", GLOBALREPLACE )
);
userentry = Associative Array( wordList );

Show(userentry);

// 2. Process column values: Uppercase if needed, then remove leading zeros in the formula
dt &amp;lt;&amp;lt; New Column( "Suspected " || selectedCol,
	Formula(
		target_val = Char( As Column( selectedCol ) );
		If( Case sensitive == 0, target_val = Uppercase( target_val ) );
		
		// Remove leading zeros from column value before comparison
		target_val = Regex( target_val, "^0*", "", GLOBALREPLACE );
		
		If( userentry &amp;lt;&amp;lt; Contains( target_val ), 
			"Yes", 
			"No" 
		)
	)
);




dt &amp;lt;&amp;lt; Move Selected Columns({Name Expr( As Column( "Suspected " || selectedCol ) )},After( As Column( selectedCol ) ));

// Capture the end time
end_time = Tick Seconds();

// Calculate total duration
duration = end_time - start_time;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 03 Mar 2026 14:32:02 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-make-Uppercase-Regex-and-Contain-function-efficient/m-p/933595#M108982</guid>
      <dc:creator>ConfidenceOwl94</dc:creator>
      <dc:date>2026-03-03T14:32:02Z</dc:date>
    </item>
    <item>
      <title>Re: How to make Uppercase, Regex and Contain function efficient?</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-make-Uppercase-Regex-and-Contain-function-efficient/m-p/933609#M108983</link>
      <description>&lt;P&gt;What is the script supposed to do?&lt;/P&gt;</description>
      <pubDate>Tue, 03 Mar 2026 14:34:20 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-make-Uppercase-Regex-and-Contain-function-efficient/m-p/933609#M108983</guid>
      <dc:creator>jthi</dc:creator>
      <dc:date>2026-03-03T14:34:20Z</dc:date>
    </item>
    <item>
      <title>Re: How to make Uppercase, Regex and Contain function efficient?</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-make-Uppercase-Regex-and-Contain-function-efficient/m-p/933615#M108986</link>
      <description>&lt;DIV&gt;It creates a &lt;STRONG&gt;“Suspected Column1”&lt;/STRONG&gt; column and marks &lt;STRONG&gt;“Yes”&lt;/STRONG&gt; when the value in &lt;STRONG&gt;Column1&lt;/STRONG&gt; matches the user input. I have few additional steps that summarizes which user inputs were found and which were missing. But Those steps are efficient so I did not included them.&amp;nbsp;&lt;/DIV&gt;</description>
      <pubDate>Tue, 03 Mar 2026 14:43:14 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-make-Uppercase-Regex-and-Contain-function-efficient/m-p/933615#M108986</guid>
      <dc:creator>ConfidenceOwl94</dc:creator>
      <dc:date>2026-03-03T14:43:14Z</dc:date>
    </item>
    <item>
      <title>Re: How to make Uppercase, Regex and Contain function efficient?</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-make-Uppercase-Regex-and-Contain-function-efficient/m-p/933619#M108988</link>
      <description>&lt;P&gt;In your example table you are comparing numeric values to characters. What types of checks are you trying to do:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;&lt;STRIKE&gt;You say match but the code is saying contain&lt;/STRIKE&gt;&lt;/LI&gt;
&lt;LI&gt;Code is also saying &lt;STRIKE&gt;contain&lt;/STRIKE&gt; WITH data modifications&lt;/LI&gt;
&lt;LI&gt;The example table you provided has numeric values, but you are comparing them to characters&lt;/LI&gt;
&lt;LI&gt;Edit: are all the values unique?&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;Edit: the code is looking for "exact matches" as it utilizes Contains with Associative Array. Biggest issue here is the amount of data and comparison between numbers and characters. The check can be most likely optimized with some evaluations but depending on the real issue, there might be plenty other optimizations to be done.&lt;/P&gt;</description>
      <pubDate>Wed, 04 Mar 2026 06:35:49 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-make-Uppercase-Regex-and-Contain-function-efficient/m-p/933619#M108988</guid>
      <dc:creator>jthi</dc:creator>
      <dc:date>2026-03-04T06:35:49Z</dc:date>
    </item>
  </channel>
</rss>

