2
Answers

replacing characters in strings

I have some live data which contains personal information (names/addresses). I want to jumble it so I can take a copy of it as test data without worrying about security.

I want to parse the string and replace characters as follows

Any character in 'a, e, i, o, u' I will replace with another character from the same list

Any character in 'c, g, j, k, q, s, x, z' I will replace with another character from the same list etc.

So 'a' might be replaced with 'e', then 'i' etc

In rough pseudo code terms

foreach (char c in nameStr)
  switch(char)
    case 'a,e,i,o,u': replace with random from array of a,e,i,o,u

I've not got a huge amount of data to trawl through and I can just set this off and leave it running so speed isn't that much of an issue.

Cheers Martin.

Answers (2)