2012-06-08 47 views
-4

您好,感谢您的关注。条件搜索并替换C#

编辑:我不是一个程序员,我几乎不知道的C#或其他任何语言,所以,很抱歉的问题,我一直在寻找一个解决方案,但没有任何工程。谢谢你低估了我的问题。

为了这一点,我得到这个代码:

using System; 
using VisualWebRipper.Internal.SimpleHtmlParser; 
using VisualWebRipper; 
public class Script 
{ 

    public static string TransformContent(WrContentTransformationArguments args) 
    { 
     try 
     { 
      //Place your transformation code here. 
      //This example just returns the input data 

      return args.Content; 
     } 
     catch(Exception exp) 
     { 
      //Place error handling here 
      args.WriteDebug("Custom script error: " + exp.Message); 
      return "Custom script error"; 
     } 
    } 
} 

我需要用C#做一个条件这让我找到* args.Content(谁包含变量字符串)字符串“没有限制“,如果查找匹配,则将字符串值更改为数字(0)并将其返回。如果不是没有改变。

所以,我只需要搜索和替换字符串转换成一个数字,如果它与字符串“无SE莲花Exige”相匹配。

许多感谢的努力阅读我的英语水平,希望你能帮助我:)

+1

你尝试过这么远吗?不要指望这个网站做的功课你没有表现出任何的努力... – walther

+0

几个例子会使描述更加清楚千倍 – Snowbear

+1

http://www.whathaveyoutried.com - 请阅读它,为我们着想和我们的同胞兄弟。 – Arran

回答

0

只需使用Replace方法:

args.Content = args.Content.Replace("No se exige", "0"); 
+0

为什么downvote它回答的? 。问题 –

+1

presumeably他们downvoted,因为他们希望用户尝试一些自己和真正学到一些东西,但您选择正确的,因为它回答了这个问题,所以我upvoted取消它 – RhysW

+0

感谢队友,它的工作原理:) –