Subscribe Bookmark RSS Feed

How to find and delete rows in a data table containing a text (or elements in a list)

woongkim79

Community Trekker

Joined:

May 24, 2013

I have a list containing a combinations of letters ... e.g A B C D...

Column1

A

B

C

D

AB

AC

AD

ABC

ABD

..... so forth or as a list e.g. mylist = {A, B, C, D, AB, AC, AD, ABC, ABD....}.

While it is possible to find those cells starting with "AB" using Edit-Search-Find from the table menu, it is strange I cannot find a way to do this using JSL script.

I would imagine something like:

loc (mylist,"AB?") for a list or

current data table << get rows where (Column 1 == "AB?") for a data table

...should work but they don't.

Can anyone suggest a way to locate these values using a wildcard (i.e. AB?) or other clever ways to find these items and delete them?

Thank you in advance.

1 ACCEPTED SOLUTION

Accepted Solutions
Solution

This is a perfect situation for using regular expressions.  For a table you can use the REGEX function:

dt = open("$sample_data/Car Physical Data.jmp");

ch_rows = dt << get rows where(regex(:Model, "^Ch") == "Ch");

That code snippet will find all rows beginning with the string "Ch".

2 REPLIES
Solution

This is a perfect situation for using regular expressions.  For a table you can use the REGEX function:

dt = open("$sample_data/Car Physical Data.jmp");

ch_rows = dt << get rows where(regex(:Model, "^Ch") == "Ch");

That code snippet will find all rows beginning with the string "Ch".

woongkim79

Community Trekker

Joined:

May 24, 2013

Beautiful!  Thank you so much PMroz.