如何在string.Format方法中输出大括号({})
2012-02-12 12:52
489 查看
C#(a.cs)
编译运行:
结论: {{ 得到
{ , }} 得到 }
更多信息可参考:http://msdn.microsoft.com/zh-cn/library/txafckwd.aspx
using System; public class Test { public void Middle(string start, string end) { string pat1 = string.Format("(?<={0}).*(?={1})", start, end); Console.WriteLine(pat1); string pat2 = string.Format("(?<={{0}}).*(?={{1}})", start, end); Console.WriteLine(pat2); string pat3 = string.Format("(?<={{{0}}}).*(?={{{1}}})", start, end); Console.WriteLine(pat3); } public static void Main(string[] args) { string start = "12"; string end = "35"; Test t = new Test(); t.Middle(start, end); } }
编译运行:
E:\>csc a.cs Microsoft(R) Visual C# 2010 编译器 4.0.30319.1 版 版权所有(C) Microsoft Corporation。保留所有权利。 E:\>a.exe (?<=12).*(?=35) (?<={0}).*(?={1}) (?<={12}).*(?={35}) E:\>
结论: {{ 得到
{ , }} 得到 }
更多信息可参考:http://msdn.microsoft.com/zh-cn/library/txafckwd.aspx
相关文章推荐
- 如何在string.Format方法中输出大括号({})
- 如何在string.Format方法中输出大括号({})
- 在C#(CSharp)中如何使用string.Format输出大括号{}
- 如何在string.Format()方法中输出大括号
- MessageFormat对象实现格式化字符串输出,类似C#中的string.format方法
- C# string.Format() 方法中输出大括号
- java格式化输出 JAVA String.format 方法使用介绍
- 巧妙处理StringBuilder.AppendFormat 方法中字符串含有花括号“{}”
- Eval("string", string format) 如何输出格式转换??
- 巧妙处理StringBuilder.AppendFormat 方法中字符串含有花括号“{}”
- MessageFormat对象实现格式化字符串输出,类似C#中的string.format方法
- string.format中如何添加大括号{
- String.format字符串格式化方法
- 为javascript添加String.Format方法
- JAVA中 String.format方法的使用
- JAVA String.format 方法使用介绍
- C#:String.Format数字格式化输出
- string.format输出大括号
- JAVA String.format 方法使用介绍
- 用DateTime.ToString(string format)输出不同格式的日期