Formating a String

I have a string similar to the one shown below. I want first letter of every word to be capitalized (otherwise lowercase), everything before "/" will still be capitalized.

TET/TEST TEST TESTING

whats the best method of doing this?
pfslinkAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

planoczCommented:
Are these Directories or Text files or what?
0
pfslinkAuthor Commented:
just a string passed from the db
0
planoczCommented:
Here is a sample using Regular Expressions.....


Imports System.Text.RegularExpressions
Public Class Form1
    Inherits System.Windows.Forms.Form

#Region " Windows Form Designer generated code "

    Public Sub New()
        MyBase.New()

        'This call is required by the Windows Form Designer.
        InitializeComponent()

        'Add any initialization after the InitializeComponent() call
        UseRegularExpression("TET/TEST TEST TESTING")
    End Sub

    'Form overrides dispose to clean up the component list.
    Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
        If disposing Then
            If Not (components Is Nothing) Then
                components.Dispose()
            End If
        End If
        MyBase.Dispose(disposing)
    End Sub

    'Required by the Windows Form Designer
    Private components As System.ComponentModel.IContainer

    'NOTE: The following procedure is required by the Windows Form Designer
    'It can be modified using the Windows Form Designer.  
    'Do not modify it using the code editor.
    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
        components = New System.ComponentModel.Container
        Me.Text = "Form1"
    End Sub

#End Region

    Private Sub UseRegularExpression(ByVal strName As String)
        Dim regExp As New Regex("([a-zA-Z]{1,})\/{1}\s{0,}([a-zA-Z]{1,})\s{0,}([a-zA-Z]{0,})")
        Dim matchGroups As GroupCollection = regExp.Match(strName).Groups
        Dim sDir As String

        sDir = UCase(matchGroups(1).Value) & "/"
        sDir += UCase(matchGroups(2).Value.Substring(0, 1)) & LCase(matchGroups(2).Value.Substring(1))
        sDir += UCase(matchGroups(3).Value.Substring(0, 1)) & LCase(matchGroups(3).Value.Substring(1))

        MsgBox(sDir)

    End Sub
End Class
0
Cloud Class® Course: Microsoft Windows 7 Basic

This introductory course to Windows 7 environment will teach you about working with the Windows operating system. You will learn about basic functions including start menu; the desktop; managing files, folders, and libraries.

Bob LearnedCommented:
 Dim testString As String = "TET/TEST TEST TESTING"

  Dim slashPos As Integer = testString.IndexOf("/")

  Dim properCase As String = StrConv(testString.Substring(slashPos + 1), VbStrConv.ProperCase)
  Dim upperCase As String = testString.Substring(0, slashPos).ToUpper

Bob
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
dharmesh_amityCommented:
I guess best thing to do here is use string and String.Split() method. I have never used string tokenizer it but you can look up.

I got this piece of code from http://www.csharpfriends.com/Articles/getArticle.aspx?articleID=28

private void Page_Load(object sender, System.EventArgs e)
{
   
    // string seperated by colons ';'
    string info = "mark;smith;123 csharp drive;toronto;canada";

    string[] arInfo = new string[4];
   
    // define which character is seperating fields
    char[] splitter  = {';'};
           
    arInfo = info.Split(splitter);

    for(int x = 0; x < arInfo.Length; x++)
    {
        Response.Write(arInfo[x] + "<br>");
    }

}


Hope that is helpful
0
pfslinkAuthor Commented:
the program is in vb.net
0
muzzy2003Commented:
Haven't tested this, I mostly use C#, but should do the trick.

Dim delimiter As String = "/"
Dim delimiterChars As Char() = delimiter.ToCharArray()
Dim parts As String()
Dim myTI As TextInfo = New CultureInfo("en-US", False).TextInfo

parts = testString.Split(("/").ToCharArray())
testString = parts[0] + "\" + myTI.ToTitleCase(parts[1])
0
muzzy2003Commented:
Sorry - change that to:

Dim delimiter As String = "/"
Dim delimiterChars As Char() = delimiter.ToCharArray()
Dim parts As String()
Dim myTI As TextInfo = New CultureInfo("en-US", False).TextInfo

parts = testString.Split(delimiterChars)
testString = parts[0] + "\" + myTI.ToTitleCase(parts[1])
0
dharmesh_amityCommented:
Just need to change the syntax for VB.NET as muzzy2003 suggested
0
pfslinkAuthor Commented:
where is TextInfo defined?

how about parts[0], what is this referring to?
0
muzzy2003Commented:
It is defined in System.Globalization - add an "Imports" for this to the top of the code. parts[0] refers to the first part of the array formed in the previous line - basically, everything before the \.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic.NET

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.