在C#中的字符串中查找在某些点具有任何字符的字符串
我想不出最好的方法来解释这个问题,但是如何做像在C#中的字符串中查找在某些点具有任何字符的字符串,c#,string,character,any,C#,String,Character,Any,我想不出最好的方法来解释这个问题,但是如何做像text.Replace(“1*6”,“hello”) 其中,*表示一个可以是任何东西的字符/数字,因此,“116”、“126”、“1e6”等都将以相同的方式处理,并被替换为“hello”这对您很有用: var text = "This is 1x6 in a string."; var result = Regex.Replace(text, "1.6", "hello"); 这给了我以下结果: 这是一串你好 这将对您有用: var text
text.Replace(“1*6”,“hello”)
其中,
*
表示一个可以是任何东西的字符/数字,因此,“116”
、“126”
、“1e6”
等都将以相同的方式处理,并被替换为“hello”
这对您很有用:
var text = "This is 1x6 in a string.";
var result = Regex.Replace(text, "1.6", "hello");
这给了我以下结果:
这是一串你好
这将对您有用:
var text = "This is 1x6 in a string.";
var result = Regex.Replace(text, "1.6", "hello");
这给了我以下结果:
这是一串你好
这将对您有用:
var text = "This is 1x6 in a string.";
var result = Regex.Replace(text, "1.6", "hello");
这给了我以下结果:
这是一串你好
这将对您有用:
var text = "This is 1x6 in a string.";
var result = Regex.Replace(text, "1.6", "hello");
这给了我以下结果:
这是一串你好
使用正则表达式:
string input = "126";
string output = Regex.Replace(input, "1.6", "hello");
有关regex的更多信息:
使用正则表达式:
string input = "126";
string output = Regex.Replace(input, "1.6", "hello");
有关regex的更多信息:
使用正则表达式:
string input = "126";
string output = Regex.Replace(input, "1.6", "hello");
有关regex的更多信息:
使用正则表达式:
string input = "126";
string output = Regex.Replace(input, "1.6", "hello");
有关regex的更多信息:
使用正则表达式替换
static class Program
{
/// <summary>
/// Regular expression built for C# on: Thu, Jul 3, 2014, 02:47:43 PM
/// Using Expresso Version: 3.0.4750, http://www.ultrapico.com
///
/// A description of the regular expression:
///
/// 1.6
/// 1
/// Any character
/// 6
///
///
/// </summary>
public static Regex regex = new Regex(
"1.6",
RegexOptions.CultureInvariant
| RegexOptions.Compiled
);
// This is the replacement string
public static string regexReplace =
"hello";
static void Main(string[] args)
{
string input = @"
116,
1e6
";
string result = regex.Replace(input, regexReplace);
Console.WriteLine(result);
}
}
静态类程序
{
///
///为C#on构建的正则表达式:2014年7月3日星期四下午2:47:43
///使用Expresso版本:3.0.4750,http://www.ultrapico.com
///
///正则表达式的说明:
///
/// 1.6
/// 1
///任何字符
/// 6
///
///
///
公共静态正则表达式Regex=新正则表达式(
"1.6",
RegexOptions.CultureInvariant
|RegexOptions.Compiled
);
//这是替换字符串
公共静态字符串regexReplace=
“你好”;
静态void Main(字符串[]参数)
{
字符串输入=@“
116,
1e6
";
字符串结果=regex.Replace(输入,regexReplace);
控制台写入线(结果);
}
}
使用正则表达式替换
static class Program
{
/// <summary>
/// Regular expression built for C# on: Thu, Jul 3, 2014, 02:47:43 PM
/// Using Expresso Version: 3.0.4750, http://www.ultrapico.com
///
/// A description of the regular expression:
///
/// 1.6
/// 1
/// Any character
/// 6
///
///
/// </summary>
public static Regex regex = new Regex(
"1.6",
RegexOptions.CultureInvariant
| RegexOptions.Compiled
);
// This is the replacement string
public static string regexReplace =
"hello";
static void Main(string[] args)
{
string input = @"
116,
1e6
";
string result = regex.Replace(input, regexReplace);
Console.WriteLine(result);
}
}
静态类程序
{
///
///为C#on构建的正则表达式:2014年7月3日星期四下午2:47:43
///使用Expresso版本:3.0.4750,http://www.ultrapico.com
///
///正则表达式的说明:
///
/// 1.6
/// 1
///任何字符
/// 6
///
///
///
公共静态正则表达式Regex=新正则表达式(
"1.6",
RegexOptions.CultureInvariant
|RegexOptions.Compiled
);
//这是替换字符串
公共静态字符串regexReplace=
“你好”;
静态void Main(字符串[]参数)
{
字符串输入=@“
116,
1e6
";
字符串结果=regex.Replace(输入,regexReplace);
控制台写入线(结果);
}
}
使用正则表达式替换
static class Program
{
/// <summary>
/// Regular expression built for C# on: Thu, Jul 3, 2014, 02:47:43 PM
/// Using Expresso Version: 3.0.4750, http://www.ultrapico.com
///
/// A description of the regular expression:
///
/// 1.6
/// 1
/// Any character
/// 6
///
///
/// </summary>
public static Regex regex = new Regex(
"1.6",
RegexOptions.CultureInvariant
| RegexOptions.Compiled
);
// This is the replacement string
public static string regexReplace =
"hello";
static void Main(string[] args)
{
string input = @"
116,
1e6
";
string result = regex.Replace(input, regexReplace);
Console.WriteLine(result);
}
}
静态类程序
{
///
///为C#on构建的正则表达式:2014年7月3日星期四下午2:47:43
///使用Expresso版本:3.0.4750,http://www.ultrapico.com
///
///正则表达式的说明:
///
/// 1.6
/// 1
///任何字符
/// 6
///
///
///
公共静态正则表达式Regex=新正则表达式(
"1.6",
RegexOptions.CultureInvariant
|RegexOptions.Compiled
);
//这是替换字符串
公共静态字符串regexReplace=
“你好”;
静态void Main(字符串[]参数)
{
字符串输入=@“
116,
1e6
";
字符串结果=regex.Replace(输入,regexReplace);
控制台写入线(结果);
}
}
使用正则表达式替换
static class Program
{
/// <summary>
/// Regular expression built for C# on: Thu, Jul 3, 2014, 02:47:43 PM
/// Using Expresso Version: 3.0.4750, http://www.ultrapico.com
///
/// A description of the regular expression:
///
/// 1.6
/// 1
/// Any character
/// 6
///
///
/// </summary>
public static Regex regex = new Regex(
"1.6",
RegexOptions.CultureInvariant
| RegexOptions.Compiled
);
// This is the replacement string
public static string regexReplace =
"hello";
static void Main(string[] args)
{
string input = @"
116,
1e6
";
string result = regex.Replace(input, regexReplace);
Console.WriteLine(result);
}
}
静态类程序
{
///
///为C#on构建的正则表达式:2014年7月3日星期四下午2:47:43
///使用Expresso版本:3.0.4750,http://www.ultrapico.com
///
///正则表达式的说明:
///
/// 1.6
/// 1
///任何字符
/// 6
///
///
///
公共静态正则表达式Regex=新正则表达式(
"1.6",
RegexOptions.CultureInvariant
|RegexOptions.Compiled
);
//这是替换字符串
公共静态字符串regexReplace=
“你好”;
静态void Main(字符串[]参数)
{
字符串输入=@“
116,
1e6
";
字符串结果=regex.Replace(输入,regexReplace);
控制台写入线(结果);
}
}
你的意思是,像正则表达式一样?你想要像1*6然后1hello6那样作为输出?看看吧。我想是的,但是*只代表一个可以是任何东西的字符,而不是多个可能重复的字符。你的意思是,像正则表达式一样?你想要像1*6然后1hello6那样作为输出吗?看看吧。我想是的,但是*只代表一个可以是任何东西的字符,而不是多个可能的重复字符,你的意思是,像正则表达式一样?你想要1*6然后1 hello6作为输出?看看吧。我想是的,但是*只代表一个可以是任何东西的字符,而不是多个可能的重复字符,你的意思是,像正则表达式一样?你想要像1*6那么1 hello6作为输出吗?看看吧。我想是的,但是*只代表一个可以是任何东西的字符,而不是多个可能的重复字符