Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

I need to compare 2 similar strings and choose upper case when available

Posted on 2011-03-24
3
Medium Priority
?
323 Views
Last Modified: 2012-05-11
I have two instances of a name and need to merge them thusly:

Activity
activities

should create
Activities

How can I do this in C#?

newbieweb
0
Comment
Question by:newbieweb
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 9

Accepted Solution

by:
jerrypd earned 2000 total points
ID: 35207115
you need logic to determine how "similar" the words are to determine if they are the same.
for example Activities and activate, or active...
once you have that logic, then you just need to set the first character to uppercase.
But, given the weirdness of the english language, I think the hardest part will be the "rules" for similar words...
0
 

Author Closing Comment

by:newbieweb
ID: 35207128
thanks.
0
 
LVL 7

Expert Comment

by:dimaj
ID: 35207159
I'm not sure if this will work 100% of the time, but my approach would be as follows:
1) Loop through both strings character-by-character
2) Compare current character's ascii numbers
3a) If absolute value of ascii of  str1 - ascii of str2 == 32, then pick the one with a lower number (that's your upper case)
3b) if ascii of str1 == ascii of str2, pick whichever one you like
4) If you're at the end of one of the strings, go back one and append leftovers from the other string

4th step will basically handle your substitution of 'y' for 'ies'

I hope this will get you started.
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…

722 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question