如何删除一些Spacel字符 [英] How can remove some Spacel Characters

查看:84
本文介绍了如何删除一些Spacel字符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

< p> 从农舍到工业时尚,从城市阁楼一直到选择!< / p>







删除此字符:< p>



for sql server

<p> From farmhouse to industrial chic, from the urban loft all the way out selection!</p>



remove this characters: <p>

for sql server

推荐答案





有一个看看MSSQL REPLACE 功能。



您可以使用它删除您的html字符,例如:

Hi,

Have a look at MSSQL REPLACE function.

You can use it to remove your html character, like:
SELECT        
REPLACE(REPLACE('<p> From farmhouse to industrial chic, from the urban loft all the way out selection!</p>', '<p>', '') , '</p>', '')





替换mult iple字符,你需要嵌套REPLACE函数。



[edit]更新以替换开始和结束标签[/ edit]



...希望它有所帮助。



To replace multiple characters, you need to nest the REPLACE function.

[edit]Updated to replace start and end tags[/edit]

... hope it helps.


不要。

虽然删除那些特定字符并不困难但是它很差想法 - 用HTML格式模糊的格式很容易弄错。



相反,使用谷歌可以找到的众多HTML解析器之一解析整个文档,然后从中提取所需的信息。
Don't.
While it's not difficult to remove those specific characters, it's a poor idea - it's very easy to get it wrong with a format as vague as HTML.

Instead, use one of the many, many HTML parsers you can find via Google to parse the entire document and then extract just the info you want from that.


要删除特殊字符,可以使用下面的代码行。这将仅替换特殊字符。



To remove special characters you can use the below line of code. This will replace special characters only.

DECLARE @RegularExp INT
Declare @Str varchar(500)
SET @Str='<p> From farmhouse to industrial chic, from the urban loft all the way out selection!</p>'
SET @RegularExp = PATINDEX('%[^a-zA-Z0-9 ]%', @Str)
WHILE @RegularExp > 0
BEGIN
SET @Str = STUFF(@Str, @RegularExp, 1, ' ' )
SET @RegularExp = PATINDEX('%[^a-zA-Z0-9 ]%', @Str)
END
SELECT @Str





如果你想替换html标签,那么你将不得不使用sql的替换功能。



If you want to replace html tags then you will have to use replace function of sql.


这篇关于如何删除一些Spacel字符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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