How to match part of text in 2 column?Hi everyone, I would like to ask about this data set
| ID | Column A | Column B | Column C
| Column D |
| 1 | A*05:01 A*25:01 B*08:01 B*39:01 C*05:01 C*07:06 C*07:18 C*12:03 DRB1*05:01 DRB1*07:01 DRB3*01:01 DRB4*09:03N DQA1*02:01 DQA1*05:01 DQB1*02:01 DQB1*02:02 | DQA1*01-03,DQB1*06-03_DQ6 | | |
| 2 | A*20:01 A*60:02 B*08:01 B*28:03 C*02:02 C*03:04 DRB1*01:02 DRB1*13:04 DRB3*02:02 DRB3*02:02 DQA1*01:01 DQA1*01:04 DQA1*01:05 DQA1*05:05 DQA1*05:09 DQB1*02:01 DQB1*05:01 | DQA1*05-01,DQB1*02-01_DQ2 | | |
| 3 | A*01:01 A*01:01 B*08:01 B*38:01 C*06:02 C*09:01 C*07:06 C*07:18 DRB1*07:01 DRB1*07:01 DRB4*01:01 DRB4*01:03 DRB4*01:05N DQA1*02:01 DQA1*02:01 DQB1*02:02 DQB1*03:03 | DQA1*03-03,DQB1*04-01_DQ4 | | |
| 4.... | A*01:01 A*01:01 B*08:01 B*38:01 C*06:02 C*09:01 C*07:06 C*07:18 DRB1*07:01 DRB1*07:01 DRB4*01:01 DRB4*01:03 DRB4*01:05N DQA1*02:01 DQA1*03:03 DQB1*02:02 DQB1*03:03 | DQA1*03-03,DQB1*04-01_DQ4 | DQA1*02:01 DQA1*03:03 DQB1*02:02 DQB1*03:03 | DQA1*03:03 |
Q1: How can i do? I want to extract text only DQA1... and DQB1... in column A into column C.
Q2: How can I do? I want to match the extract text in column B and column C in the same row into column D
I try to use the regex command - but the problem occur with * and :, and I have no idea how to match part of text with two column in multiple ID...
I put the thing that I want into the ID 4., in this case : and - are the same.
Thank you for your help in advance!
Basic Data Analysis and ModelingmacOSRe: How to match part of text in 2 column?For Column D you could use Words(), Substitute() and Associative Array() + Intersect, in a formula, to find exact matches
aa1 = Associative Array(Words(:Column B, ","));
aa2 = Associative Array(Words(Substitute(:Column C, ":", "-"), " \!N"));
aa1 << Intersect(aa2);
Concat Items(aa1 << Get Keys, ",");
For Column C you can get good ideas from Regex: can't get all parts of the string that match
Edit:
Here is one option for Column C which might work. If you don't understand what it does, I suggest using While loop and Regex as that is generally easier to understand than JMP's pattern matching.
result = {};
Pat Match(
:Column A,
Pat Repeat(
(Pat Regex("(DQ[AB]1.+)[\s$]") >> result)
|
Pat Len(1)
)
);
Concat Items(Words(result, " "), ", ");

Re: How to match part of text in 2 column?Open the table and check out the formulas added to Column C and Column D (they both have formulas).

If you are not sure how to create formulas in JMP, check out JMP Help page https://www.jmp.com/support/help/en/17.2/#page/jmp/create-formulas-in-jmp.shtml#