C#:
string mystring = "Hello World. & my name is < bob >. Thank You."
Console.Writeline(mystring.ToUpper())
I am trying to get all the text to be uppercase except--
& < >
Because these are my encoding and the encoding wont work unless the text is lower case.
You may split the string with a space, turn all the items not starting with
&
to upper and just keep the rest as is, and then join back into a string:Another approach is to use a regex to match
&
, 1+ word chars and then a;
, and match and capture other 1+ word char chunks and only turn to upper case the contents in Group 1: