Re: How to use Regex to intercept a specified range of content into a table?dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
dt << Add Rows( 5, at end );
Wait( 0 );
Current Data Table() << Bring Window To Front;
Main Menu( "Copy With Column Names" );
txt = Get Clipboard();
Re: How to use Regex to intercept a specified range of content into a table?Thanks!
Re: How to use Regex to intercept a specified range of content into a table?In this simple case there is no need for regex and you can just get index from the list. If more complicated comparison is needed it should be fairly easy to build a loop to go through the list
Names Default To Here(1);
dt = Open("$SAMPLE_DATA/Big Class.jmp");
dt << Add Rows(5, at end);
dt << Select columns("name");
Main Menu("Copy With Column Names", dt << Get Window Title);
clipb = Get Clipboard();
txt = Trim Whitespace(clipb);
l_all = Words(txt, "\!N");
break_str = "HENRY";
l_interested = Substr(l_all, Contains(l_all, break_str));
dt_new = New Table("table",
Add Rows(N Items(l_interested)),
New Column("col", Character, Nominal, Values(l_interested));
);

Re: How to use Regex to intercept a specified range of content into a table?I Want to continue learning efficient code from the experts.
If the data OBTAINED from the clipBOARD HAS 3 columns per day and is separated by Spaces, not Tabs.

How to modify the code to get a table with three columns like this.
Thank jthi !
Re: How to use Regex to intercept a specified range of content into a table?Many ways to handle this. Here is one idea using Data table subscripting
Names Default To Here(1);
dt = Open("$SAMPLE_DATA/Big Class.jmp");
dt << Add Rows(5, at end);
dt << Select columns({"name", "age", "sex"});
Main Menu("Copy", dt << Get Window Title);
clipb = Get Clipboard();
txt = Trim Whitespace(clipb);
// Substitute Into(txt, " ", "\!t"); // could replace spaces with tabs
l_all = Words(txt, "\!N");
// Using \!t for demo purposes
list_of_lists = Transform Each({line}, l_all, Words(line, "\!t"));
dt_new = New Table("table",
Add Rows(N Items(l_all))
);
dt_new << Delete Column(1);
For(i = 1, i <= N Items(list_of_lists[1]), i++,
dt_new << New Column("col" || char(i), Character, Nominal);
);
dt_new[0,0] = list_of_lists;Re: How to use Regex to intercept a specified range of content into a table?I'm still using JMP 14
This code is not running.
list_of_lists = Transform Each({line}, l_all, Words(line, "\!t"));Thank jthi !
Re: How to use Regex to intercept a specified range of content into a table?Change it to normal for-loop. Something like this should work
list_of_lists = {};
For(i = 1, i <= N Items(l_all), i++,
Insert Into(list_of_lists, Eval List({Words(l_all[i], "\!t")}))
);Re: How to use Regex to intercept a specified range of content into a table?list_of_lists = {};
For(i = 1, i <= 3, i++,
Insert Into(list_of_lists, Eval List({Words(l_all, " ")}))
);How to use Regex to intercept a specified range of content into a table?Hello!
Assumption: The original data is obtained in the clipboard with consecutive empty lines at the end, and the rows that are not empty are not copied.
How to use the RE to intercept the content starting after the line containing the specified content and ending on the empty line.Copy to the new table.
For example: "Big Class.JMP"
And it says "ALFRED"
It get my new table.
Scripting