473,232 Members | 1,426 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,232 software developers and data experts.

Example code, String divided.

namespace System
{
public class Text
{
public static System.Char Omin='\t',Next='
',Wciecie='\"',Zamkniecie='\"',Null='\0',Object=' ';
public static System.Int32 NextCharacter(System.Int32 i,System.Char[]
litery,System.Char wciecie,System.Char nastepny)
{
for(;i<litery.Length;i++)
{
if(litery[i]==wciecie)
{
return i;
}
if(litery[i]==nastepny)
{
return i;
}
}
return i;
}
public static System.Int32 NextWord(System.Int32 i,System.Char[]
litery,System.Char wciecie,System.Char zamkniecie,System.Char
nastepny,System.Char omin,ref System.String word)
{
for(;i<litery.Length;i++)
{
if(litery[i]==zamkniecie)
{
return i;
}
else if(litery[i]==wciecie)
{
return i;
}
else if(litery[i]==nastepny)
{
return i;
}
else if(litery[i]==omin)
{
return i;
}
else
{
word+=litery[i].ToString();
}
}
return i;
}
public static System.Int32 PoliczWord2(System.String tekst,System.Char
wciecie,System.Char nastepny,System.Char omin)
{
System.Int32 i=0,n=0;
System.Char[] litery=tekst.ToCharArray();
while(i<litery.Length)
{
if(litery[i]==wciecie)
{
i=NextCharacter(i+1,litery,wciecie,Null)+1;
n++;
}
else if(litery[i]==nastepny)
{
i++;
}
else if(litery[i]==omin)
{
i++;
}
else
{
i=NextCharacter(i,litery,wciecie,nastepny);
n++;
}
}
if(i==0)
{
return 0;
}
return n;
}
public static System.String[] Word2(System.String tekst,System.Char
wciecie,System.Char nastepny,System.Char omin)
{
System.String[] wordy=new
System.String[PoliczWord2(tekst,wciecie,nastepny,omin)];
System.Int32 i=0,n=0;
System.Char[] litery=tekst.ToCharArray();
while(i<litery.Length)
{
if(litery[i]==wciecie)
{
i=NextWord(i+1,litery,wciecie,wciecie,Null,Null,re f wordy[n])+1;
n++;
}
else if(litery[i]==nastepny)
{
i++;
}
else if(litery[i]==omin)
{
i++;
}
else
{
i=NextWord(i,litery,wciecie,wciecie,nastepny,omin, ref wordy[n]);
n++;
}
}
return wordy;
}
public static int PoliczWord(System.String tekst)
{
return PoliczWord2(tekst,Wciecie,Next,Omin);
}
public static System.String[] WordFrom(System.String tekst)
{
return Word2(tekst,Wciecie,Next,Omin);
}
public static System.String Word(System.String tekst,System.Int32 numer)
{
System.String word="";
System.Int32 i=0,n=0;
System.Char[] litery=tekst.ToCharArray();
System.Char wciecie=Wciecie,nastepny=Next,omin=Omin;
while(i<litery.Length)
{
if(litery[i]==wciecie)
{
i=NextWord(i+1,litery,wciecie,wciecie,Null,Null,re f word)+1;
if(n==numer)
{
return word;
}
else
{
word="";
}
n++;
}
else if(litery[i]==nastepny)
{
i++;
}
else if(litery[i]==omin)
{
i++;
}
else
{
i=NextWord(i,litery,wciecie,wciecie,nastepny,omin, ref word);
if(n==numer)
{
return word;
}
else
{
word="";
}
n++;
}
}
return word;
}
}
}
pi*********@hotmail.com
Feb 6 '06 #1
2 1606
???

"PioM" <pi**@192.168.2.118> wrote in message
news:ds**********@atlantis.news.tpi.pl...
namespace System
{
public class Text
{
public static System.Char Omin='\t',Next='
',Wciecie='\"',Zamkniecie='\"',Null='\0',Object=' ';
public static System.Int32 NextCharacter(System.Int32 i,System.Char[]
litery,System.Char wciecie,System.Char nastepny)
{
for(;i<litery.Length;i++)
{
if(litery[i]==wciecie)
{
return i;
}
if(litery[i]==nastepny)
{
return i;
}
}
return i;
}
public static System.Int32 NextWord(System.Int32 i,System.Char[]
litery,System.Char wciecie,System.Char zamkniecie,System.Char
nastepny,System.Char omin,ref System.String word)
{
for(;i<litery.Length;i++)
{
if(litery[i]==zamkniecie)
{
return i;
}
else if(litery[i]==wciecie)
{
return i;
}
else if(litery[i]==nastepny)
{
return i;
}
else if(litery[i]==omin)
{
return i;
}
else
{
word+=litery[i].ToString();
}
}
return i;
}
public static System.Int32 PoliczWord2(System.String tekst,System.Char
wciecie,System.Char nastepny,System.Char omin)
{
System.Int32 i=0,n=0;
System.Char[] litery=tekst.ToCharArray();
while(i<litery.Length)
{
if(litery[i]==wciecie)
{
i=NextCharacter(i+1,litery,wciecie,Null)+1;
n++;
}
else if(litery[i]==nastepny)
{
i++;
}
else if(litery[i]==omin)
{
i++;
}
else
{
i=NextCharacter(i,litery,wciecie,nastepny);
n++;
}
}
if(i==0)
{
return 0;
}
return n;
}
public static System.String[] Word2(System.String tekst,System.Char
wciecie,System.Char nastepny,System.Char omin)
{
System.String[] wordy=new
System.String[PoliczWord2(tekst,wciecie,nastepny,omin)];
System.Int32 i=0,n=0;
System.Char[] litery=tekst.ToCharArray();
while(i<litery.Length)
{
if(litery[i]==wciecie)
{
i=NextWord(i+1,litery,wciecie,wciecie,Null,Null,re f wordy[n])+1;
n++;
}
else if(litery[i]==nastepny)
{
i++;
}
else if(litery[i]==omin)
{
i++;
}
else
{
i=NextWord(i,litery,wciecie,wciecie,nastepny,omin, ref wordy[n]);
n++;
}
}
return wordy;
}
public static int PoliczWord(System.String tekst)
{
return PoliczWord2(tekst,Wciecie,Next,Omin);
}
public static System.String[] WordFrom(System.String tekst)
{
return Word2(tekst,Wciecie,Next,Omin);
}
public static System.String Word(System.String tekst,System.Int32 numer)
{
System.String word="";
System.Int32 i=0,n=0;
System.Char[] litery=tekst.ToCharArray();
System.Char wciecie=Wciecie,nastepny=Next,omin=Omin;
while(i<litery.Length)
{
if(litery[i]==wciecie)
{
i=NextWord(i+1,litery,wciecie,wciecie,Null,Null,re f word)+1;
if(n==numer)
{
return word;
}
else
{
word="";
}
n++;
}
else if(litery[i]==nastepny)
{
i++;
}
else if(litery[i]==omin)
{
i++;
}
else
{
i=NextWord(i,litery,wciecie,wciecie,nastepny,omin, ref word);
if(n==numer)
{
return word;
}
else
{
word="";
}
n++;
}
}
return word;
}
}
}
pi*********@hotmail.com

Feb 6 '06 #2
PioM <pi**@192.168.2.118> wrote:
namespace System
{
public class Text


Aside from anything else (like the reason for the post) it's a bad idea
to start populating the System namespace yourself, and a *really* bad
idea to create a type called System.Text when there's already a
namespace with that name.

Now, did you have a question?

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
Feb 6 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: sachin bond | last post by:
The following code(in c++) is supposed to divide a file into 'n' different files. suppose i'm having a file called "input.zip". The execution of the following code should divide "input.zip"...
16
by: Jason | last post by:
Hi, I need a way to use random numbers in c++. In my c++ project, when using the mingw compiler I used a mersenne twister that is publicly available and this did its job well. Now I have...
11
by: Lues | last post by:
Hi, I'm trying to protect some data in tables with encription (you know why, don't you ;)) I must confess that I'm not very expirienced in writing code, especially encription code. Can any...
11
by: sethukr | last post by:
hi everybody, char str="string"; str^=str; can anybody plz tell me the use of ^operator in string??? -Sethu
3
by: =?Utf-8?B?QnJpYW4gQ29vaw==?= | last post by:
In my project I want to search thru a text in a text box or RichTextBox. When I search I want to list all lines that contain the string I am searching for. e.g. one plus four two plus four...
3
by: WP | last post by:
Hello! I need some help with my program...it's supposed to read infix expressions line by line from stdin and each expression should be divided into operands and operators and added to a vector of...
31
by: somenath | last post by:
Hi All, I was going through one of the exercise of one C tutorial . In that they have given one small code and asked about the output. #include <stdio.h> int main(void) { int x =...
4
by: Semajthewise | last post by:
Hi All For those of you that helped me with the questions on this... Thank you! I believe I have solved all the bugs in the code and wanted to post the final product. This is a set of code to solve...
1
by: Semajthewise | last post by:
Here it is cleaned up a little more. Here's what this code does. It will take 2 fractions and add, subtract, multiply, or divide them. The user enters the fractions to be calculated into two...
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 3 Jan 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). For other local times, please check World Time Buddy In...
0
by: jianzs | last post by:
Introduction Cloud-native applications are conventionally identified as those designed and nurtured on cloud infrastructure. Such applications, rooted in cloud technologies, skillfully benefit from...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: stefan129 | last post by:
Hey forum members, I'm exploring options for SSL certificates for multiple domains. Has anyone had experience with multi-domain SSL certificates? Any recommendations on reliable providers or specific...
1
by: davi5007 | last post by:
Hi, Basically, I am trying to automate a field named TraceabilityNo into a web page from an access form. I've got the serial held in the variable strSearchString. How can I get this into the...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
0
by: Aftab Ahmad | last post by:
Hello Experts! I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...
0
by: Aftab Ahmad | last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below. Dim IE As Object Set IE =...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.