Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

regexp for html tags with Matlab

I'm looking for a way to use regexp in order to remove all html tags from a string.
So if I have <HTML><b><FONT color="red" size="3">Hello</FONT></b></HTML> I would like to get the hello from it.

I know it will probably look like nested tags, but it's not really, because all I want to do here is to remove anything between two <>.

I'm using Matlab for doing so, but the regexp is the exact same, so feel free to contribute any help.
Thank you.

like image 652
shahar_m Avatar asked May 03 '11 08:05

shahar_m


2 Answers

My solution is:

>> str='<HTML><b><FONT color="red" size="3">Hello</FONT></b></HTML>';
>> regexprep(str, '<.*?>','')

ans =

Hello
like image 164
ilalex Avatar answered Oct 04 '22 20:10

ilalex


To match such a tag

<[^>]*>

See online here at Rubular

like image 31
stema Avatar answered Oct 04 '22 20:10

stema