Re: Camel Case from String

  • Thread starter Nicholas Paldino [.NET/C# MVP]
  • Start date
N

Nicholas Paldino [.NET/C# MVP]

Jon,

It pretty much is. I mean, it's one thing to lowercase the string, but
you aren't specifying the criteria under which the camel case is to be
applied. How will you know that the "N" should be capitalized? Without
some sort of dictionary (of all possible words) or some other marker
indicating a word break, there is no way you could do this.

Hope this helps.


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

Jon said:
Hello all,

is there a method or reg exp. that people know of, or have used, that will
convert a string such as FIRSTNAME to Camel Case (FirstName)? It seems like
an impossible task I know but I thought I'd ask the community as see what
comes to light.
 
N

Nicholas Paldino [.NET/C# MVP]

Jon,

When I say dictionary, I mean a dictionary file that has all the words
in the english language in it, which you would use to perform some sort of
lexical analysis on the string. There is no standard dictionary file in the
framework, but rather, a Dictionary class, which is not what I was referring
to.


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

Jon said:
Thanks for that Nicholas. Confirmed my suspicions. I may work on some sort
of solution for my next project by using the inbuilt dictionary or
something?
 
J

Jon Skeet [C# MVP]

Jon said:
Thanks for that Nicholas. Confirmed my suspicions. I may work on some
sort of solution for my next project by using the inbuilt dictionary
or something?

Only if you're prepared for some problems. For instance, how would you
camel case:

SOMETHING (SoMeThing, Something, SomeThing)
CAMELOT (Camelot, CameLot)
TAPEWORM (Tapeworm, TapeWorm)
LEGLESS (LegLess, Legless)

etc

Basically there are any number of combinations of words which can be
split in more than one way.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top