Technology - string

来源:互联网 发布:python书籍 编辑:程序博客网 时间:2024/05/30 02:22

 

 

public static int ReverseIndexOf(string s, char c)

{

 

Char[] tempChar = s.ToCharArray();

 

Array.Reverse(tempChar);

 

return (new string(tempChar).IndexOf(c) == -1 ? s.Length : s.Length - new string(tempChar).IndexOf(c));

}

 

 

 

 

 

 

 

 

 

 

 

 

 

 

///

<summary>

 

 

///

restore missing Cr for comments

 

 

///

background: BE will lost Cr when save and get comments. GUI control show multi-line content must use CrLf.

 

 

///

Phase 3 by suchun

 

 

///

</summary>

 

 

///

<param name="OrgStr"></param>

 

 

///

<returns></returns>

 

 

public static string Lf2CrLf(string

OrgStr)

{

 

 

if (!String

.IsNullOrEmpty(OrgStr))

{

 

 

return System.Text.RegularExpressions.Regex.Replace(OrgStr, "(?<!/r)/n", "/r/n"

);

}

 

 

else

 

 

return String

.Empty;