Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
Last post May 02, 2012 11:41 PM by Paul Linton
May 02, 2012 08:36 PM|LINK
i want to create a regular expression to find and replace uppercase character based on some condition.
Find the starting uppercase for a group of uppercase character in a string and replace it lowercase and "*" before the starting uppercase.
If there is any lowercase following the uppercase,replace the uppercase with lowercase and "*" before the starting uppercase.
input string : stackOVERFlow
expected output : stack*over*flow
i tried but could not get it working perfectly.
Any idea on how to create a regular expression ?
May 02, 2012 11:41 PM|LINK
I don't do regular expressions but Linq is quite up to the challange
string x = "stackOVERFlow";
var y = x.ToCharArray()
((char.IsLower(x[pos]) && char.IsUpper(x[pos+1])) || //lower to upper
(char.IsUpper(x[pos+1]) && x.Length>pos+1 && char.IsLower(x[pos+2])) // upper to lower
.Aggregate (x.Substring(0,1), (sofar,c) => sofar+c );