Re: string plit

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



Alan,

Therefore you have to find what character is at the end of each line. Not
tested but written in this message I think that I would do it something like
this to see what it is.

string myString = "Whatever";
int Lastcharacter = myString[myString.Count];

You should than get the charatcter at the last line of your string.

Than you can set that as a char in your split.

I hope this helps,

Cor

"Alan T" <alanpltseNOSPAM@xxxxxxxxxxxx> schreef in bericht
news:uL9a1W8zGHA.1268@xxxxxxxxxxxxxxxxxxxxxxx
Hi,

I almost can get my string split working, however, still got little
problem.
I got a text file in which a strange character, ie a little rectangle at
the end of each line. So when I call string split, I also got the little
rectangle with the word.

eg.
Hello world enquiry

After the split I got
Hello
world
enquiry

this is my code:
string fileText;

string[] keywords;

char[] charSeparators = new char[] { ' ', '\r', '\n', ',', '\t' };

try

{fileText = File.ReadAllText(aFile);

keywords = fileText.Split(charSeparators,
StringSplitOptions.RemoveEmptyEntries);

...

}

catch

{

}






"Cor Ligthert [MVP]" <notmyfirstname@xxxxxxxxx> wrote in message
news:O$FKdI$yGHA.480@xxxxxxxxxxxxxxxxxxxxxxx
Alan,

Why not try it yourself.

\\\
string myString = "What is \r\nthis";
char[] charSeparators = new char[] { ' ', '\r', '\n' };
string [] keywords = myString.Split(charSeparators,
StringSplitOptions.RemoveEmptyEntries);
foreach (string keyword in keywords)
{
MessageBox.Show(keyword);
}
///

I hope this helps,

Cor

"Alan T" <alanpltseNOSPAM@xxxxxxxxxxxx> schreef in bericht
news:%23MTZok%23yGHA.3704@xxxxxxxxxxxxxxxxxxxxxxx
string[] keywords;

char[] charSeparators = new char[] { ' ' };

keywords = aKeywords.Split(charSeparators,
StringSplitOptions.RemoveEmptyEntries);

foreach (string keyword in keywords)

{

MessageBox.Show(keyword);

_documentDA.DeleteDocumentKeyword(aDoc, keyword);

}

I can split the string into words if they are separated by a space.

How about if I have a string separated by space characters and return?

eg.

I entered "Hello world !" in the first line of a rich text box and press
"ENTER" key to the second line. Then enter "My name is Alan".

I just wonder the "!My" will be treated as one word.








.



Relevant Pages

  • Re: search 1000 keywords in doc.
    ... Dim strText As String ... 'Open your keywords document ... 'Close your keywords document ... For lngCounter = 0 to UBound ...
    (microsoft.public.word.vba.general)
  • Re: string plit
    ... I think that little rectangle is a sort of non-Window thing, ... Therefore you have to find what character is at the end of each line. ... You should than get the charatcter at the last line of your string. ... keywords = fileText.Split(charSeparators, ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Algoritim - Create Unique Integer from String
    ... back to the original string), only that a unique string produce a unique ... spam categorizer uses some sort of one-way hash for its Naive Bayes ... It breaks the messages up into keywords, ... before it stores them in the database (or compares them to existing ...
    (comp.programming)
  • RE: Extracting keywords from a string
    ... Keywords table. ... Function GetLongWords(ByVal strText As String, ... Dim intSpacePos As Integer ... Dim strWord As String, strWordList As String ...
    (microsoft.public.access.queries)
  • Re: Negate a character sequence in a regular expression?
    ... The engine starts scanning through the string until matches 'cat'. ... where cat and dog were separated by only a few ... but the frequency of appearance of the keywords ... you need to add the /m modifier if your strings are paragraphs. ...
    (comp.lang.ruby)