필터 지우기
필터 지우기

Parse a string between two similar expression

조회 수: 2 (최근 30일)
KnowledgeSeeker
KnowledgeSeeker 2014년 2월 5일
편집: per isakson 2014년 2월 6일
I am writing a program that basically aim to parse the word between to similar expression and store a word in a cell array.
I want to use
regexp to math the two expression and only return and store the word in between the two expressions. any suggestions
[matchedExpression, parsedWord] = regexp (text, [& nbsp;'\w*' & nbsp;], 'split');
Example:
text= '$ nbsp;words& nbsp;'
I want to get the words
output= words
Thanx
  댓글 수: 2
Matt Kindig
Matt Kindig 2014년 2월 5일
Can you provide an example illustrating what you are trying to do?
KnowledgeSeeker
KnowledgeSeeker 2014년 2월 5일
Thank you. I have edited my question

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

답변 (1개)

per isakson
per isakson 2014년 2월 5일
편집: per isakson 2014년 2월 6일
lookaround seems to suite your need.
text = '$ nbsp;words& nbsp;';
cac = regexp( text, '(?<=\$ nbsp;).+?(?=\& nbsp;)', 'match' );
returns {'words'}
If "words" stands for more than one word and you want to 'split' them, do that in a second step.

카테고리

Help CenterFile Exchange에서 String Parsing에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by