Skip to content

Instantly share code, notes, and snippets.

@xsurge83
Created September 26, 2012 15:57
Show Gist options
  • Save xsurge83/3788851 to your computer and use it in GitHub Desktop.
Save xsurge83/3788851 to your computer and use it in GitHub Desktop.
Regex to replace password
using NUnit.Framework;
namespace REGEX.TESTS
{
[TestFixture]
public class RegexTests
{
[Test]
public void Regex()
{
var requestBodyJson = "{\"Username\":\"Tom\",\"Password\"}";
var test = Regex.Replace(requestBodyJson, "\"Password\":\"[^\"]*\"", "\"Password\":\"*******\"");
Assert.IsTrue(test.Contains("\"Password\":\"***\""));
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment