Need help making very specific regexp

I have list of strings to apply a regular expression to. Some of them have HTML tags, some don't. It basically looks like this:
astring={'<HTML><FONT color="blue">taggedtext</Font></HTML>';'someothertext1';'someothertext2'...etc}
I'm trying to right a regular expression to get the 'taggedtext' if there are HTML tags and get 'someothertext1', etc. if there are not tags. I'm interested in doing this in ONE expression, I've already found plenty of ways to do it with other functions or multiple regular expressions.
This is the closest I've come:
expressyoself='(<?)(?(1)>(\w+)<{1}|(\w+){1})'
[mat tok]=regexp(astring,expressyoself,'match','tokens','warnings');
Which returns the correct values for all the non-tagged items, but returns the following for the tagged ones (cell array)
'HTML' 'FONT' 'color' 'blue' 'taggedtext' 'Font' 'HTML'
If anyone can figure this out, it'd be greatly appreciated.
Thanks!

回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeCharacters and Strings についてさらに検索

質問済み:

Jay
2012 年 5 月 9 日

Community Treasure Hunt

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

Start Hunting!

Translated by