Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

I have this problem with a string, you see it always seems to come out like something like this:

 

hhheeellllloooooo

 

And I was wondering if there was a way to like delete the extras so that it would come out looking like this:

 

helo

 

:)

"Reality is fake, Dreams are for real"
  • *Experts*
Posted
You could do this:
for (int i = 0; i <= 26; i++) {
 String lc = Convert.ToChar(i + 97).ToString();
 String uc = Convert.ToChar(i + 65).ToString();

 // Replace twice so that triplets are reduced to 1:
 // 1) aaaaaa -> aaaa
 // 2) aaaa -> a
 myText = myText.Replace(lc + lc, lc).Replace(lc + lc, lc);
 myText = myText.Replace(uc + uc, uc).Replace(uc + uc, uc);
}

A bit hackish I suppose, but it should work (I haven't tested it though).

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...