Click to See Complete Forum and Search --> : Using split() command


minority
12-10-2005, 04:10 PM
Hi

I got more of a question rather than that of a problem (Although a problem too)

Basically i have a sentence (String) that is in questionin and need to split it into single words so i need to remove all of the ,.""'';:!&^?/\ spaces etc.

when use this function it seems to slightly work
Textdelimiter = “/<[^>]*>/g “ removing all of the brackets etc but not full stops.

I know it is a regular expression but thought i could add to it eg full stop question marks all the things that must be removed to leave pure strings of words.

So when I add this it goes pair shape

Textdelimiter = “/.,?\|&+-~#{}<[^>]*>/g “
questionOut = Split(questionin,textdelimiter)

So basically I am just asking if either I need to add it a certain way or is there a different way of securing what i am trying to achieve?

Thanks for any help

Cstick
12-12-2005, 11:48 PM
How about something like this?

Dim x As String = "asdf 3434 asd /.,/2asfas"
Dim y As String
Dim z As New ArrayList
For Each C As Char In x.ToCharArray
If Char.IsLetterOrDigit(C) Then
y &= C
Else
If y <> "" Then
z.Add(y)
y = ""
End If
End If
Next
If y <> "" Then z.Add(y)
Dim arr As String() = z.ToArray(GetType(String))

minority
12-13-2005, 12:53 PM
Im really sorry but kind of new to all of this and just wonder if you could explain what this is doing.

basically i am taking an xml in like the Battery (B3EE) is over heating and exploding.

i need to get rid of all of the ().,;:/\|?{}[]()*&^%""! etc.

I am gathering the above is handled by string x....am i right.and c is the input variable that i get from xml.

Is this correct.

takkie
12-13-2005, 02:33 PM
in that above code.

x will be the word you are searching.

and c is each character within x.

it is examing each c within x character by character. if c is a valid character or number, then dump it into a new string...

-Tak

Cstick
12-13-2005, 04:43 PM
Exactly, it is basically creating an array of words composed strictly of letters and digits. For the example, the following array of words is created: "asdf","3434","asd","2asfas".

minority
12-13-2005, 07:31 PM
ahh k thanks it late but i will try it tomo and see if that does it thanks again.

On a side note will this effect the output of words like don't etc?