Parse a string between two similar expression

1 Ansicht (letzte 30 Tage)
KnowledgeSeeker
KnowledgeSeeker am 5 Feb. 2014
Bearbeitet: per isakson am 6 Feb. 2014
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 Kommentare
Matt Kindig
Matt Kindig am 5 Feb. 2014
Can you provide an example illustrating what you are trying to do?
KnowledgeSeeker
KnowledgeSeeker am 5 Feb. 2014
Thank you. I have edited my question

Melden Sie sich an, um zu kommentieren.

Antworten (1)

per isakson
per isakson am 5 Feb. 2014
Bearbeitet: per isakson am 6 Feb. 2014
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.

Kategorien

Mehr zu Characters and Strings finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by