带有Matlab的html标签的正则表达式 [英] regexp for html tags with Matlab

查看:17
本文介绍了带有Matlab的html标签的正则表达式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在寻找一种使用正则表达式的方法,以便从字符串中删除所有 html 标记.
所以如果我有 <HTML><b><FONT color="red" size="3">Hello</FONT></b></HTML> 我想从中获取 hello.

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 <>.

我正在使用 Matlab 来执行此操作,但正则表达式完全相同,因此请随时提供任何帮助.
谢谢.

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

推荐答案

我的解决方案是:

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

ans =

Hello

这篇关于带有Matlab的html标签的正则表达式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆