1. Remove the beginning and end strings
Copy the codeThe code is as follows:
///<summary>
/// Before and after characters (string)
///</summary>
///<param name="val">original string</param>
///<param name="str">String to be cut off</param>
///<param name="all">Is it greedy</param>
///<returns></returns>
private string GetString(string val,string str,bool all)
{
return (val, @"(^(" + str + ")" + (all ? "*" : "") + "|(" + str + ")"+(all ? "*" : "") + "$)", "");
}
2. Remove the beginning and end characters
Copy the codeThe code is as follows:
/// <summary>
///
/// </summary>
/// <param name="val">original string</param>
/// <param name="c">characts to be intercepted</param>
/// <returns></returns>
private string GetString(string val,char c)
{
return (c).TrimEnd(c);
}