replace = with u003d c#

If I skip the json part and assume you want to insert the pattern “\n” and “\u003d” in that original base-64 string then you need to escape in the Replace statement, as below enter image description here

The code for 2 scenarios

    string t1 = @"oKQmwbpPwZGxUGeWQNBucVmNy1JVsxM9uNivn6hpkia+15y3yIemkW8GXW423krf8WNk6yebQixZ
W78EpPMMtzldQbbsaEmd4aUDCwp78ivOuh83nC8fHy2gwkm5NcS7aaGm2KxkUsWa5ouNUa7BUWPZ
3F7LXFR / SLjZRTMY8u7hwYEQCmUQk / zNXsLyHHwZQiOjZfXdb1nC4vu1LItxaw == ";

    var b1 = t1.Contains(Environment.NewLine);  //return true
    // The line below will insert the pattern "\n" and "\u003d"
    string t2 = t1.Replace(System.Environment.NewLine, "\\n").Replace("=", "\\u003d");

    // otherwise (Environment.NewLine is \r\n)
    string t3 = t1.Replace(System.Environment.NewLine, "\n").Replace("=", "u003d");
    var b2 = t3.Contains(Environment.NewLine);  //return false

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top