简体   繁体   English

将关键字从 javascript 拆分为 C#

[英]Split keyword from javascript to C#

How can I split this JavaScript:如何拆分此 JavaScript:

 encodeUri(this.value).split("/%..|./").length - 1;

to C#?到 C#? Should I use regex for this?我应该为此使用正则表达式吗? I'm trying the snippet below to c# but error on the "/%..|./".我正在尝试将下面的代码片段转换为 c#,但在“/%..|./”上出错。 It says that cannot convert from string to char.它说不能从字符串转换为字符。

 HttpUtility.Html.Encode(value).Split(@"/%..|./").Length - 1;

There is no overload of the method String.Split that takes only one string as an input. String.Split方法没有重载, String.Split接受一个字符串作为输入。

You probably want something like this:你可能想要这样的东西:

HttpUtility.HtmlEncode(value).Split(new [] {"/%..|./"}, StringSplitOptions.None);
// or even:
HttpUtility.HtmlEncode(value).Split("/%..|./", StringSplitOptions.None);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM