reading a string for predefined size

S

sony.m.2007

Hi,
I have a large string and i need to split the string into 5
characters.
for example
string st="test1234567890test1234567dfghhhjrt57ujkk8"
I want to split the above string st into strings of 5 characters.
if the string length is 33 means, the output string count is 7.
6 string contains 5 characters and 7th one will contain 3 only.
Is there string function available to do this?

Thanks,
Sony
 
C

Christophe Lephay

Hi,
I have a large string and i need to split the string into 5
characters.
for example
string st="test1234567890test1234567dfghhhjrt57ujkk8"
I want to split the above string st into strings of 5 characters.
if the string length is 33 means, the output string count is 7.
6 string contains 5 characters and 7th one will contain 3 only.
Is there string function available to do this?

It looks like some homework to do. Isn't it ?
 
S

sony.m.2007

Hi,
I have a large string and i need to split the string into  5
characters.
for example
string st="test1234567890test1234567dfghhhjrt57ujkk8"
I want to split the above string st into strings of 5 characters.
if the string length is 33 means, the output string count is 7.
6 string contains 5 characters and 7th one will contain 3 only.
Is there string function available to do this?

It looks like some homework to do. Isn't it ?[/QUOTE]

Hi,

I already completed the splitting with substring function.
I would like to know is there any other easiest function available

Thanks,
Sony
 
G

Göran Andersson

Hi,
I have a large string and i need to split the string into 5
characters.
for example
string st="test1234567890test1234567dfghhhjrt57ujkk8"
I want to split the above string st into strings of 5 characters.
if the string length is 33 means, the output string count is 7.
6 string contains 5 characters and 7th one will contain 3 only.
Is there string function available to do this?

Thanks,
Sony

There's a one-liner for everything. ;)

string[] x = (from Match m in Regex.Matches(st, @"[\W\w]{1,5}") select
m.Value).ToArray();
 
S

sony.m.2007

Hi,
I have a large string and i need to split the string into  5
characters.
for example
string st="test1234567890test1234567dfghhhjrt57ujkk8"
I want to split the above string st into strings of 5 characters.
if the string length is 33 means, the output string count is 7.
6 string contains 5 characters and 7th one will contain 3 only.
Is there string function available to do this?
Thanks,
Sony

There's a one-liner for everything. ;)

string[] x = (from Match m in Regex.Matches(st, @"[\W\w]{1,5}") select
m.Value).ToArray();

Hi,
Great.
That's the simple way I want.
Thank a lot

Cheers,
Sony
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top