C#正则表达式查找器 [英] C# Regex finder

查看:167
本文介绍了C#正则表达式查找器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

ITNOG-嗨

谢谢您的迅速而非常好的回答,这确实对我有所帮助.

但我有一个新问题,希望您能帮助我:

无论是否存在"@",我都想将此字符串更改为新字符串.例如,其中两个应替换为:

ITNOG - Hi

Thank you for your quick and very good answer , that really helped me .

but I have got some new question , hope you help me please :

I want to change this string to new string whether there is ''@'' or not. For example two of them should replace to that :

string file = "this is a sample text";




or

string file = @"this is a sample text";




to

string file = Function(@"this is a sample text");


如果有Function()方法,也应该不要再次使用:


also if there is a Function() method , should not be used again :

string file = Function(@"this is a sample text");




to

string file = Function(@"this is a sample text");


我知道这真的很难找到,但是我找不到,希望有人帮我.


I know this is really hard to find , but I am not able to find that , wish someone help me .

推荐答案

对不起,如果以下内容没有出现.代码项目似乎有一个错误.当我单击预览"选项卡时,以下代码中的某些内容阻止了该代码显示.哦,好吧,我们只是希望这是一个预览问题,并且答案一经发布便会真正出现:

Sorry if the below doesn''t show up. Code Project seems to have a bug. Something in the below code is preventing it from showing up when I click the "Preview" tab. Oh well, let''s just hope is a preview problem and that this actually does show up once the answer is posted:

// This goes at the top of your file.
using System.Text.RegularExpressions;

// This code does what you want.
string pattern = @"(?<RESULT>\"".*?\"")";
string replace = "Function(


{RESULT})"; 字符串输入= @字符串文件="这是示例文本";"; 字符串结果= Regex.Replace(input,pattern,replace); MessageBox.Show(result);
{RESULT})"; string input = @"string file = ""this is a sample text"";"; string result = Regex.Replace(input, pattern, replace); MessageBox.Show(result);


这篇关于C#正则表达式查找器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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