-
Jun 7th, 2007, 02:17 AM
#1
Thread Starter
Lively Member
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
-
Jun 7th, 2007, 03:07 AM
#2
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
-
Jun 7th, 2007, 03:21 AM
#3
Thread Starter
Lively Member
Re: how to split a word into letters and compare with a array of letters
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
-
Jun 7th, 2007, 03:49 AM
#4
Thread Starter
Lively Member
Re: how to split a word into letters and compare with a array of letters
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
-
Jun 7th, 2007, 09:55 AM
#5
Re: how to split a word into letters and compare with a array of letters
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.
-
Jun 8th, 2007, 01:28 PM
#6
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|