.NETGURU
How to find out if character is in caps or not?
Messages   Related Types
This message was discovered on microsoft.public.dotnet.languages.vb.
Responses highlighted in red are from those people who are likely to be able to contribute good, authoratitive information to this discussion. They include Microsoft employees, MVP's and others who IMHO contribute well to these kinds of discussions.
Post a new message to this list...

Martin Ho
What I really need is a short simple solution for this scenario:

Imagine word like this:
"TheSimpleSolution"
I need to turn it to:
"The Simple Solution"

I need a solution, something which would turn connected words and
separate them using spaces. Basically, a script which would add the
space ahead of each capitalized character.

Please, be so good and let me know, I know I am pretty much asking for
ready script, but whatever you mention, whatever help or sugestion
will be much appreciated.

Thanks a lot.
Martin

Reply to this message...
 
    
Martin Ho
Fabricio ,
I don't know how to thank you... you saved me a lot of time and I
really appreciate it.
Thanks a lot.
Martin

backup of this question:
http://www.groupsrv.com/dotnet/viewtopic.php?t=69327

Reply to this message...
 
    
Fabricio (VIP)
No problem bud :-)

-Fabricio
Click here to reveal e-mail address

"Martin Ho" wrote:

[Original message clipped]

Reply to this message...
 
    
Fabricio (VIP)
Here she goes Martin...

Public Function SplitWords(ByVal s as string) as string
Dim strAns as string
Dim c as char

For Each c in s
If Char.IsUpper(c) Then
strAns += " "
End If

strAns += c
Next

Return strAns
End Function

-Fabricio
Click here to reveal e-mail address

"Martin Ho" wrote:

[Original message clipped]

Reply to this message...
 
    
Cor Ligthert
Fabricio,

Seeing your code I am sure you know the Stringbuilder and just are thinking
something as "why use that for such a simple string".

I have seen that even for short strings the stringbuilder gives beter result
and sometimes OPs are giving a simple sample to use it for long strings.

For Martin, with the stringbuilder the code from Fabricio can be.

Public Function SplitWords(ByVal s as string) as string
Dim strAns as new system.text.stringbuilder
Dim c as char
For Each c in s
If Char.IsUpper(c) Then
strAns.append( " ")
End If
strAns.append(c)
Next
Return strAns.tostring
End Function
>

Cor

Reply to this message...
 
    
Fabricio (VIP)
I don't use the Stringbuilder object much... actually I've never used it.
When you say it "gives better results" do you mean performance. Is it more
efficient than a built-in string object. Also, how's its overhead compared
to the string object? Thanks for the info Cor.

-Fabricio
Click here to reveal e-mail address

P.S. What's OP?

"Cor Ligthert" wrote:

[Original message clipped]

Reply to this message...
 
    
Cor Ligthert
Fabricio,

I can can add a lot to the message from Herfried,

What he not explained was OP which means Original Poster

However when you have still question, feel free to ask.

Cor

[Original message clipped]

Reply to this message...
 
    
Herfried K. Wagner [MVP] (VIP)
* "=?Utf-8?B?RmFicmljaW8=?=" <Click here to reveal e-mail address> scripsit:
[Original message clipped]

Strings in .NET are immutable, contantenating two strings will create a
new string object that consists of the concatenated strings. 'StringBuilder'
overcomes this issue.

I suggest to take a look at the documentation for the 'System.String'
and 'System.Text.StringBuilder' classes.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>
Reply to this message...
 
    
Herfried K. Wagner [MVP] (VIP)
* Click here to reveal e-mail address (Martin Ho) scripsit:
[Original message clipped]

\\\
Imports System.Text
..
..
..
MsgBox(ExpandCaps("ThisIsVeryGood"))
..
..
..
Public Function ExpandCaps(ByVal Text As String) As String
Dim Buffer As New StringBuilder(CInt(Text.Length * 1.3))
For Each c As Char In Text
If Char.IsUpper(c) Then
Buffer.Append(" "c)
End If
Buffer.Append(c)
Next c
Return Buffer.ToString()
End Function
///

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>
Reply to this message...
 
 
System.Buffer
System.Char
System.String
System.Text.StringBuilder




ExamGuru IT Solutions - .Net Guru is owned and operated by ExamGuru, Inc., the man behind .Net Guru. If you're in the market for bespoke software or software consultancy, why not get him and his highly trained team to help? - www.examguru.net/ITCertification
Ad


Need Dot Net Interview Questions?
Ask ExamGuru, Inc. for advice and help on Passing .Net Interviews
.Net Projects
Best-of-breed application framework for .NET projects, developed by ExamGuru, Inc. and ExamGuru IT
Free .net Help
Commission ExamGuru, Inc. and his team for your next bespoke software project
FogBUGZ
The only bug tracking system carefully crafted with one goal in mind: helping teams create great software.
Awesome Tools
If you don't know about these, you're missing out... IT Certification Questions
IT Interview Questions
Free Oracle 10g Training
MCSE Boortcamp
Cisco Study Guides
Cheap Study Guides
Exact Questions
Dot Net Interview Questions
Oracle OCP
Cheap Travel
Designer Perfumes - Wholesale Prices
Free Programming Tutorials
 
ExamGuru IT Solutions - .Net Guru is owned and operated by ExamGuru, Inc., the man behind .Net Guru. If you're in the market for bespoke software or software consultancy, why not get him and his highly trained team to help? - www.examguru.net/ITCertification
 Copyright © ExamGuru, Inc. 2001-2006
Contact Us - Terms of Use - Privacy Policy - www.dot-net-guru.com - www.examguru.net - www.oraclesource.net - www.itinterviews.net - www.examguru.net/ITCertification