how to split a word into letters and compare with a array of letters-VBForums
Results 1 to 6 of 6

Thread: how to split a word into letters and compare with a array of letters

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Dec 2006
    Posts
    66

    how to split a word into letters and compare with a array of letters

    i am using asp.net code behind vb

    i have a array element with vowels .
    i will get a string and i need to compare the string with the array and remove the vowels from that string and display


    sample code:

    Function fungetstring()
    Dim arrgetvowels(5)
    Dim getstring As String
    arrgetvowels(0) = "a"
    arrgetvowels(1) = "e"
    arrgetvowels(2) = "i"
    arrgetvowels(3) = "o"
    arrgetvowels(4) = "u"
    getstring = "o"
    Dim intgetcode As Integer
    For intgetcode = 0 To UBound(arrgetvowels)
    If arrgetvowels(intgetcode) = getstring Then
    Response.Write(getstring.ToString)

    Exit For
    Else

    End If

    Next
    End Function



    i am note getting it.

    any idea u get it


    thanks in advance

    with regards

    ravi

  2. #2
    Frenzied Member brin351's Avatar
    Join Date
    Mar 2007
    Location
    Land Down Under
    Posts
    1,293

    Re: how to split a word into letters and compare with a array of letters

    it would be easier to use a simple regex than looping through the strings chars and the vowel array
    like

    Dim s as String = myString
    Regex.Replace(s, "[aeiou]", "")

    --->s now has vowels removed

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Dec 2006
    Posts
    66

    Re: how to split a word into letters and compare with a array of letters

    Quote Originally Posted by brin351
    it would be easier to use a simple regex than looping through the strings chars and the vowel array
    like

    Dim s as String = myString
    Regex.Replace(s, "[aeiou]", "")

    --->s now has vowels removed

    i need to display the remaining characters

    for sample say "mystring" i need to remove vowels and display other words like mystrng

  4. #4

    Thread Starter
    Lively Member
    Join Date
    Dec 2006
    Posts
    66

    Re: how to split a word into letters and compare with a array of letters

    Quote Originally Posted by raviram
    i need to display the remaining characters

    for sample say "mystring" i need to remove vowels and display other words like mystrng


    and

    how to find a string contains one or many words

  5. #5
    Banned timeshifter's Avatar
    Join Date
    Mar 2004
    Location
    at my desk
    Posts
    2,467

    Re: how to split a word into letters and compare with a array of letters

    Quote Originally Posted by raviram
    i need to display the remaining characters

    for sample say "mystring" i need to remove vowels and display other words like mystrng
    Did you even attempt to impliment that code? That's precisely what it does. It takes mystring, removes [aeiou] from it, and redefines the string without those characters.

  6. #6
    ASP.NET Moderator mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,174

    Re: how to split a word into letters and compare with a array of letters

    Regex.Replace will return a string to you.

    Second, to count the number of words, the simplest way would be to split the string using a space as a delimiter, then getting the length of the array that results from it.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Featured


Click Here to Expand Forum to Full Width

Survey posted by VBForums.