Click here to Skip to main content
15,881,248 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
HI
I need to check the substring in uppercase or lowercase in vb.net

e.g
THIS IS TESTING - No problem
this is testing - No problem
this IS TESTING - Problem (

here we found any uppercase need to convert to propercase.


Thanks

Sivasankaran G
Posted
Comments
Sergey Alexandrovich Kryukov 17-Jan-13 7:25am    
Not clear. How "THIS IS TESTING" is not a problem? Formalize the requirements, please. What substring?
—SA

1 solution

You can make use of String.Compare with ignoreCase set to true.

You need to build in a parser that adheres to English grammar(assuming that's the only language you support) rules and then split string based on certain characters, for instance period (.) or a question mark and then change the case.

1. Extract first character and make it upper case.
2. Check for ., ?, ! etc. and next character after that(excluding space, if any) should be uppercase.
3. Are you dealing with abbreviation? If yes, have dictionary of predefined abbreviations and make sure they all are in uppercase.

HTH
 
Share this answer
 
v2
Comments
Gssankar 17-Jan-13 6:27am    
Thanks for your response, Need to compare with a single string

E.g a = "THIS is testing"

here we need to change only "THIS" to propercase no need to check "is testing"...

Output : This is testing
dan!sh 17-Jan-13 6:37am    
Updated the reply.
Sergey Alexandrovich Kryukov 17-Jan-13 7:26am    
No. You never explained your criteria. Please understand that giving example does not mean define.
—SA
dan!sh 17-Jan-13 7:28am    
That's often the case here, isn't it? I just extrapolated that example as much I felt like.
Sergey Alexandrovich Kryukov 17-Jan-13 7:35am    
Right, unfortunately. I prefer not answering in such cases. It's like development a wrong reflex. And I think being a human should be a required prerequisite. :-)
—SA

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900