Re: string plit

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



Hi,

I think that little rectangle is a sort of non-Window thing, may like Linux
thing.
It appears as a little rectangle when I open the text file and using the
MessageBox.Show.

I think I cannot make it into
char[] charSeparators = new char[] { ' ', '\r', '\n', ',', '\t' };

Because there is no way to reproduce this little rectangle.

"Cor Ligthert [MVP]" <notmyfirstname@xxxxxxxxx> wrote in message
news:OoYV1j9zGHA.1268@xxxxxxxxxxxxxxxxxxxxxxx
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: string plit
    ... 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, ... How about if I have a string separated by space characters and return? ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Matching parentheses with Regular Expressions
    ... you probably want this regex: ... You also might get rid of some of those backslashes by substituting another character, then using replaceon the string before compiling it. ... This just allows Sun to make new keywords or operators, with out breaking any existing code. ...
    (comp.lang.java.programmer)
  • Re: string plit
    ... 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 ... keywords = fileText.Split(charSeparators, ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Background color of rectangle
    ... > Sorry I wasn't clear enough, the rectangle is around a number of text ... >>> Dim fillBrush As New SolidBrush ... >> drawing the string. ... >> Dim measureStringBitmap As New Bitmap, ...
    (microsoft.public.dotnet.languages.vb)
  • 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)