.NET Questions (CLOSED)

Questions and Answers on any aspect of .NET. Now closed.

This discussion group is now closed.

Have a question about .NET development? Try stackoverflow.com, a worldwide community of great developers asking and answering questions 24 hours a day.

The archives of .NET Questions contain years of Q&A. Even older .NET Questions are still online, too.

vb.net equivalent of tr/abc/ABC/?

In perl, I can change characters using the tr/// construct.

Is there anything similar in the vb.net regex classes?

I need to replace some accented chars with non-accented equivalents - i.e.

Chris F Send private email
Thursday, February 09, 2006
Jason Send private email
Thursday, February 09, 2006
That'll replace whole strings, not individual chars.

"abcxyz" =~ /tr/ax/AX/ will convert  abcxyz to AbcXyz

"abcxyz".Replace("ax") won't do anything in this case.

I can write a loop to go thru each char in "ax" and do string.replace on the individual chars, but I was hoping there might be a built-in function for that.
Chris F Send private email
Thursday, February 09, 2006
Giorgio Galante Send private email
Thursday, February 09, 2006
You can do String.ToUpper().
Jacob Send private email
Thursday, February 09, 2006
You have to overload methos in Replace one is to replace one char with another and the second is to replace a string with another


"abcxyz".Replace("a","A") = "Abcxyz"
"abcxyz".Replace("abc","ABC") = "ABCxyz"

Thursday, February 09, 2006
I was studying transliteration this weekend in perl - I've seen no equivalent in operator form in the .NET environment.  However, you may be able to do the same thing by doing something like:

public string fakeTR(string theString, char[] org, char[] rep)
  for(int i=0;i<org.lenght;i++)
    theString = theString.Replace(org[i], rep[i]);
  return theString;

You would be able to call it with somewhat clunky but shorter:

string v = "Black in South Dakota";
v = fakeTR(v, new char[]{'B','l','a','c','k'}, new char[]{'W','h','i','t','e'});
David Seruyange Send private email
Thursday, February 16, 2006

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics
Powered by FogBugz