Parse a string between two similar expression

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

Can you provide an example illustrating what you are trying to do?
Thank you. I have edited my question

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

답변 (1개)

per isakson
per isakson 2014년 2월 5일
편집: per isakson 2014년 2월 6일

0 개 추천

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.

카테고리

도움말 센터File Exchange에서 Characters and Strings에 대해 자세히 알아보기

질문:

2014년 2월 5일

편집:

2014년 2월 6일

Community Treasure Hunt

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

Start Hunting!

Translated by