分割字符串并按照预想格式合并

public static string FormatSearchFieldOfMutiValue(string vSearchValue)
{
    var rtn = "";
    vSearchValue = vSearchValue.Trim();
    vSearchValue = vSearchValue.Replace("'", "''");

    var array = vSearchValue.Split(new char[] { ',', '', '', ';', '+', ' ' }, StringSplitOptions.RemoveEmptyEntries);

    if (array.Length > 0)
    {
        rtn = "'" + string.Join("','", array.Where(n => n != "")) + "'";
    }
    else
    {
        rtn = "''";
    }
    return rtn;
}
原文地址:https://www.cnblogs.com/LittleBai/p/12786313.html