c# - 检查字符串仅包含和 & 仅
问题描述
我有一个字符串,我只需要检查这个字符串只包含
&&
细绳
string oldStr ="       ";
我试过这样。
bool x = !string.IsNullOrWhiteSpace(oldStr);
解决方案
Given your string is HTML which has been HTML encoded, you need to HTML decode it twice.
string oldStr = "       ";
var result = HttpUtility.HtmlDecode(HttpUtility.HtmlDecode(oldStr));
Console.WriteLine(string.IsNullOrWhiteSpace(result));
This will output true
(since a non-breaking space is whitespace).
推荐阅读
- jquery - 在更短的时间内渲染 jquery 数据表中的 mongo 集合数据
- python - Python 和 SQL Server - 如何在具有变量的多个列中进行选择?
- ios - withUnsafeMutableBytes' 已弃用 xcode 警告
- c# - 实体框架返回延迟加载查询并以另一种方法应用过滤器
- javascript - CSS 渲染后的自定义元素中是否有回调?
- c - 反转后如何正确打印子字符串
- regex - 正则表达式:匹配两个字符串之间的所有字符
- firebase - 按文档 ID 对集合 Firestore 中的文档进行排序
- c# - Angular 9 组件和 .NET Core 应用程序未作为 SPA 运行
- user-interface - 如何更改 Flutter `TextFormField` 中`labelText` 的最大长度?