C# remove empty url parameters regex

前端 未结 3 1148
轻奢々
轻奢々 2021-01-25 07:09

I am trying to remove empty url type parameters from a string using C#. My code sample is here.

    public static string test ()
    {
        string parameters          


        
3条回答
  •  -上瘾入骨i
    2021-01-25 07:49

    The results of the Regex replace is not returned by the function. The function returns the variable "parameters", which is never updated or changed.

    string parameters = "one=aa&two=&three=aaa&four=";
    ...
    string result = rgx.Replace(parameters, replacement);
    return parameters;
    ....
    

    Perhaps you meant

    return results;
    

提交回复
热议问题