Looking for alternative of extractBetween function

2 次查看(过去 30 天)
SUBHAJIT  KAR
SUBHAJIT KAR2021-11-4
评论: SUBHAJIT KAR ,2021-11-9
close all
clear all
clc
name = 'Covid_strains';
file = strcat(name,'.fasta');
sequences = fastaread(file);
The code extract the sequences from the fasta file "Covid_strains". The file contains multiple sequences. The fastaread function create a structure containing Header and Sequences. Now I want to extract the some part of the header and store it in a table. The table will be the response variable for the predictor. I wanted to use extractbetween function for this. But since I am using older version of MATLAB, the function is not available to me. Please help.
  2 个评论
SUBHAJIT  KAR
SUBHAJIT KAR 2021-11-4
I am using version 2016a. How can I extract 'B.1.2' from the the expression 'OK584715.1 |B.1.2' , using regexp ?

请先登录,再进行评论。

采纳的回答

Rik
Rik 2021-11-4
You need to come up with a regular expression that will exactly match what you want to extract. Below is my guess for what you want.
RE=['\|',... match a literal |
'(.*)',... capture any character in a token
'($|\n)'];% end of matched substring should be a newline or the end of the string
txt='OK584715.1 |B.1.2';
x=regexp(txt,RE,'tokens');x{1}
ans = 1×2 cell array
{'B.1.2'} {0×0 char}
  4 个评论

请先登录,再进行评论。

更多回答(0 个)

产品


版本

R2016a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by