How to extract data from a srting?

조회 수: 4 (최근 30일)
Vinay kumar Reddy
Vinay kumar Reddy 2013년 1월 31일
Hi,
*I have this data as a single string *
Physical Location (City):Virginia
Manager of this associate:Donna Harding
Start Date:1-1-99
ID Type:Logon for SUPERVALU associate
For Transfer Requests From Dept:
Transfer Date:
Previous UserID:
Departure Date:
Middle Name:
I want to extract the name of the manager from the
Manager of this associate:Donna Harding
I mean I want data in the above string after : to be stored in other variable.
Could anyone help me in doing this?
Thank You
  댓글 수: 3
Vinay kumar Reddy
Vinay kumar Reddy 2013년 1월 31일
Hi The posted one is the matlab input. I got a cell array,in which each cell has entire above mentioned data. each cell has different attribute for manager of the associate field.
and it has a empty line between every two lines. Thank You
Jan
Jan 2013년 1월 31일
This description as a text does not enlighten me. What is "the Matlab input"? Each cell has the data? Do you mean a cell string? With one line per cell element, or with one string and line breaks?
Again I suggest to post Matlab code due to the unbeatable clarity.

댓글을 달려면 로그인하십시오.

채택된 답변

Cedric
Cedric 2013년 1월 31일
편집: Cedric 2013년 2월 1일
Solution with a regexp:
regexp(s, '(?<=associate:).*(?=Start)', 'match')
where s contains your string.
EDIT: the following would work as well..
regexp(s, '(?<=[^)]:).*(?=Start Date)', 'match')
..does anybody have a simpler pattern proposal?
  댓글 수: 1
Vinay kumar Reddy
Vinay kumar Reddy 2013년 2월 1일
Thanks!!! Cedric
That works great!!!

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Matt J
Matt J 2013년 1월 31일
편집: Matt J 2013년 1월 31일
b='Manager of this associate';
e='Start Date';
ib=strfind(str,b);
ie=strfind(str,e);
str(ib+length(b):ie-1)

카테고리

Help CenterFile Exchange에서 Data Type Conversion에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by