从一个字符串.NET中剥去双引号 [英] Strip double quotes from a string in .NET

查看:131
本文介绍了从一个字符串.NET中剥去双引号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想匹配一些不一致的HTML格式,需要剥离出一些双引号。

I'm trying to match on some inconsistently formatted HTML and need to strip out some double quotes.

电流:

<input type="hidden">

目标:

<input type=hidden>

这是错误的,因为我不是逃避它正确的:

This is wrong because I'm not escaping it properly:

S = s.Replace(,);

s = s.Replace(""","");

这是错误的,因为没有空白字符的字符(据我所知):

This is wrong because there is not blank character character (to my knowledge):

s = s.Replace('"', '');

什么是语法/转义字符组合与一个空字符串替换双引号?

What is syntax / escape character combination for replacing double quotes with an empty string?

推荐答案

我觉得你的第一行会的实际工作,但我认为你需要包含一个一个串的四个引号(VB中至少):

I think your first line would actually work but I think you need four quotation marks for a string containing a single one (in VB at least):

s = s.Replace("""", "")

对于C#你必须用一个反斜杠逃脱引号:

for C# you'd have to escape the quotation mark using a backslash:

s = s.Replace("\"", "");

这篇关于从一个字符串.NET中剥去双引号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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