Connecting Tech Pros Worldwide Help | Site Map

divide substring

  #1  
Old July 3rd, 2009, 04:07 AM
Newbie
 
Join Date: Mar 2009
Posts: 12
hi
i have long text of around 1000 words i want this text to divide in two text . and i want to pick first text from 5th (.) dot coming in the text. how can i do this i know the use of substring and also split function in asp.net . but problum is that how can i pick from 5th(.) dot coming in the text please help me thanks in advance.
  #2  
Old July 3rd, 2009, 05:16 AM
tlhintoq's Avatar
Moderator
 
Join Date: Mar 2008
Location: Arizona, USA
Posts: 1,692
Provided Answers: 3

re: divide substring


You could split it into an array of many instead of just two, splitting on all the periods. Then combine the first 4 back into 1 string, and all the remainder into another.

Expand|Select|Wrap|Line Numbers
  1. string bob = "asd.wetr.wrt6y.sdfg.edgh";
  2. string[] bobArray = bob.Split(new char[]{'.'},5);//2nd param is max number of splits so this will make 4 little parts at each period, then leave the rest as the 5th big part.
  3. string Part1 = bobArray[0] + bobArray[1] + bobArray[2] + bobArray[3];// brute force but meant for demonstrative purpose
  4. string Part2 = bobArray[4];
  5.  
Reply


Similar Threads
Thread Thread Starter Forum Replies Last Post
Substring() Inbaraj answers 2 April 13th, 2007 12:54 AM
Advice on some code kotoro answers 12 December 9th, 2006 07:12 PM
Book: 'Beginning Visual C++ 6' By Ivor Horton dave answers 3 July 22nd, 2005 09:51 AM
Book: 'Beginning Visual C++ 6' By Ivor Horton dave answers 3 July 22nd, 2005 09:22 AM