用通配符替换值(解析文本数据)

Cov*_*ove 2 sql t-sql oracle oracle-sqldeveloper

我有包含HTML标记的行.例如

<b>Abc</b> <strong>Bca</strong>
Run Code Online (Sandbox Code Playgroud)

所以我需要把它剪掉.正如我建议我需要找到类似'%<%>%'的内容并将其替换为''.

我该怎么做?对这两种解决方案感兴趣 - MS SQL和Oracle也是如此.

Mat*_*att 8

假设调用表并调用yourtable字段htmltag.

在SQL Server中:

SELECT  
SUBSTRING(substring(htmltag,charindex('>',htmltag)+1,250),0,CHARINDEX('<',
          substring(htmltag,charindex('>',htmltag)+1 ,250),0))
FROM yourtable
Run Code Online (Sandbox Code Playgroud)

SQL FIDDLE

在Oracle中

SELECT regexp_replace(htmltag, '<[^>]+>', '') htmltag 
FROM yourtable
Run Code Online (Sandbox Code Playgroud)

SQL FIDDLE