Advertisement

05.09.2008 at 09:01AM PDT, ID: 23389877
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

string split characters
Tags: microsoft, dotnet, 2008, C#
hi i have a filename

CX3_CLARIION_ALL_cabrel_200803.doc.

i want to split it and assigned to a stirng

product=CX3_CLARIION
location=ALL;
report type=cabrel
period=200803

please help me on this. iam not sure how to split this. i think we cannot delimit by _  , but what would be the other way.

thanks
Start your free trial to view this solution
Question Stats
Zone: Programming
Question Asked By: gladstonesheeba
Solution Provided By: pfletcher631
Participating Experts: 4
Solution Grade: A
Views: 23
Translate:
Loading Advertisement...
05.09.2008 at 09:22AM PDT, ID: 21534372

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
05.09.2008 at 09:28AM PDT, ID: 21534429

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
05.09.2008 at 09:35AM PDT, ID: 21534494

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
05.09.2008 at 09:43AM PDT, ID: 21534568

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
05.09.2008 at 09:50AM PDT, ID: 21534627

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
05.09.2008 at 10:04AM PDT, ID: 21534747

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
05.09.2008 at 10:10AM PDT, ID: 21534797

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
05.09.2008 at 10:12AM PDT, ID: 21534810

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
05.09.2008 at 10:13AM PDT, ID: 21534826

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
05.09.2008 at 11:58AM PDT, ID: 21535571

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
05.09.2008 at 12:04PM PDT, ID: 21535614

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
 
Loading Advertisement...
Microsoft
  • Internet Protocols
  • Applications
  • Development
  • OS
  • Hardware
  • Windows Security
Apple
  • Operating Systems
  • Hardware
  • Programming
  • Networking
  • Software
Internet
  • Search Engines
  • File Sharing
  • WebTrends / Stats
  • Spy / Ad Blockers
  • Web Browsers
  • New Net Users
  • Web Development
  • Chat / IM
  • Anti Spam
  • Web Servers
  • Anti-Virus
  • Email Clients
Gamers
  • Tips
  • Online / MMORPG
  • Puzzle
  • Emulators
  • Action / Adventure
  • Role Playing
  • Consoles
  • Game Programming
  • Strategy
  • Sports
  • Misc
  • Computer Games
Digital Living
  • Hardware
  • New Net Users
  • New Users
  • Software
  • Digital Music
  • Gaming World
  • Home Security
  • Apple
  • Networking Hardware
Virus & Spyware
  • Vulnerabilities
  • IDS
  • Encryption
  • Anti-Virus
  • Operating Systems Security
  • Software Firewalls
  • WebApplications
  • Cell Phones
  • Operating Systems
  • Internet
  • Hardware Firewalls
Hardware
  • Handhelds / PDAs
  • Displays / Monitors
  • Components
  • Networking Hardware
  • Peripherals
  • Laptops/Notebooks
  • Storage
  • Servers
  • Desktops
  • New Users
  • Misc
  • Apple
Software
  • System Utilities
  • Industry Specific
  • Network Management
  • Photos / Graphics
  • Page Layout
  • VMWare
  • Misc
  • Web Development
  • OS
  • CYGWIN
  • Voice Recognition
  • Message Queue
  • Quality Assurance
  • Security
  • Firewalls
  • MultiMedia Applications
  • Development
  • Database
  • Office / Productivity
  • Business Management
  • OS/2 Apps
  • Server Software
  • Internet / Email
ITPro
  • OS
  • Storage
  • Encryption
  • Operating Systems Security
  • Apple Hardware
  • Laptops & Notebooks
  • Servers
  • Networking Hardware
  • Peripherals
  • Devices
  • Displays / Monitors
  • WebTrends / Stats
  • Search Engines
  • Firewalls
  • WebApplications
  • IDS
  • Vulnerabilities
  • Email Clients
  • File Sharing
  • Spy / Ad Blockers
  • Web Browsers
  • Web Servers
  • Networking
  • Anti-Virus
  • Chat / IM
  • Anti Spam
Developer
  • Web Servers
  • Web Browsers
  • Game Programming
  • Dev Tools
  • Industry Specific
  • Office / Productivity
  • Database
  • CYGWIN
  • Web Development
  • Search Engines
  • File Sharing
  • WebTrends / Stats
  • Programming
  • Content Management
  • Application Servers
  • Protocols
Storage
  • Removable Backup Media
  • Storage Technology
  • Servers
  • Grid
  • Remote Access
  • Backup / Restore
  • Misc
  • Hard Drives
OS
  • Miscellaneous
  • Security
  • Development
  • Linux
  • VMWare
  • MainFrame OS
  • Unix
  • Apple
  • OS / 2
  • AS / 400
  • BeOS
  • Microsoft
  • VMS / OpenVMS
Database
  • Oracle
  • Miscellaneous
  • MySQL
  • Software
  • Sybase
  • Contact Management
  • PostgreSQL
  • Data Manipulation
  • Clarion
  • InterSystems Cache
  • Siebel
  • MUMPS
  • OLAP
  • SQLBase
  • SAS
  • GIS & GPS
  • 4GL
  • Berkeley DB
  • DB2
  • Informix
  • Interbase / Firebird
  • FoxPro
  • Reporting
  • LDAP
  • Filemaker Pro
  • MS SQL Server
  • dBase
  • MS Access
Security
  • Misc
  • Web Browsers
  • Software Firewalls
  • Operating Systems Security
  • File Sharing
  • Spy / Ad Blockers
  • Vulnerabilities
  • WebApplications
  • IDS
  • Anti-Virus
  • Encryption
  • Anti Spam
  • Email Clients
  • VPN
  • Chat / IM
Programming
  • Editors IDEs
  • Installation
  • Handhelds / PDAs
  • Multimedia Programming
  • System / Kernel
  • Algorithms
  • Game
  • Signal Processing
  • Project Management
  • Open Source
  • Database
  • Misc
  • Languages
  • Processor Platforms
  • Theory
Web Development
  • Scripting
  • Blogs
  • Web Servers
  • Software
  • Search Engines
  • Web Graphics
  • Images
  • Internet Marketing
  • Images and Photos
  • Components
  • Document Imaging
  • Web Languages/Standards
  • Illustration
  • WebApplications
  • Fonts
  • WebTrends / Stats
  • Authoring
  • Digital Camera Software
  • Miscellaneous
Networking
  • Protocols
  • Apple Networking
  • Network Management
  • Message Queue
  • Application Servers
  • Content Management
  • File Servers
  • Email Servers
  • Misc
  • Java Editors & IDEs
  • Wireless
  • Networking Hardware
  • Backup / Restore
  • System Utilities
  • ISPs & Hosting
  • Web Servers
  • Storage Technology
  • Removable Backup Media
  • Servers
  • Broadband
  • Grid
  • OS / 2
  • Novell Netware
  • Unix Networking
  • Windows Networking
  • Security
  • Telecommunications
  • Operating Systems
  • Linux Networking
Other
  • Community Advisor
  • Lounge
  • Community Support
  • New Net Users
  • Philosophy / Religion
  • Math / Science
  • Miscellaneous
  • URLs
  • Expert Lounge
  • Politics
  • Puzzles / Riddles
Community Support
  • Suggestions
  • New to EE
  • New Topics
  • Community Advisor
  • CleanUp
  • Announcements
  • General
  • Feedback
  • Input
  • EE Bugs
 
05.09.2008 at 09:22AM PDT, ID: 21534372
you can split using "_" and for the last string split by "."

also you can use IndexOf("_") on the string to find the index and SubString() to get the string between the index.....

but i think split is easy to use.....
 
05.09.2008 at 09:28AM PDT, ID: 21534429
but if you use underscore (_)  the product string will be split in to two CX3 , Clariion. because they has the _ between them . Right?.  some of the product name has without underscore , but some has it

for example

CX3_clarriion_cabrel_all_200803.doc

Brocade_cabrel_all_200803.doc

the first portion contains the product number (CX3_clarrion)
brocade is the product number.

i want to get the product number from each of the file names ok. for that i need to split the filenames so that i can get product, period,location, report type.  please help me on this how to do this.
 
05.09.2008 at 09:35AM PDT, ID: 21534494
if the only thing that has an underscore in it sometimes is the product name, you might want to work backwards from the end of the string and simply separate using the "." and the "_" until all the fields are filled except product name, then assign everything left over to product name.

Luke
 
05.09.2008 at 09:43AM PDT, ID: 21534568
i don't understand what you are saying . could you please tell me clearly. iam sought of confused
 
05.09.2008 at 09:50AM PDT, ID: 21534627
Use a for loop to reverse the order of the filename.  Then just go through the backwards filename, starting at the "." and filling the names of the fields in reverse, period, type, location, then, when location is filled (indicated by finding the "_"), you can just say the rest of it belongs to the product name.  Then, when you're done, just use a couple for loops to get the fields in the right order again (i.e. not backwards).

Luke
 
05.09.2008 at 10:04AM PDT, ID: 21534747
are you saying like this. here's my code . please alter this if iam wrong
string product;
string reporttype;
string location;
string period;
  char[] delimiterChars = { '_', '.' };
   string[] attribs = file.Name.Split(delimiterChars);

    // pattern: product_location_cabrel_period.doc  
         product = attribs[0];
         location = file.DirectoryName;
         period = attribs[3];
         reporttype = attribs[2];
 
05.09.2008 at 10:10AM PDT, ID: 21534797
Let me look at yours real quick.  But you could brute force it like this.

Luke
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
82:
83:
84:
85:
86:
87:
88:
89:
90:
91:
92:
93:
string temp = "CX3_CLARIION_ALL_cabrel_200803.doc";
string filename = "";
string product = "";
string location = "";
string reporttype = "";
string period = "";
int i, j;
bool flag1 = false;
bool flag2 = false;
bool flag3 = false;
bool flag4 = false;
 
for (i = 0; i < temp.Length; i++)
{
	filename[i] = temp[(temp.Length - 1) - i];
}
 
 
for (i = 0; i < filename.Length; i++)
{
	if (flag1 == false)
	{
		if (filename[i] != '.')
		{
		}
		else
		{
			flag1 = true; //found the "."
			j = 0;
		}
	else
	{
		if (flag2 == false)
		{
			if (filename[i] != '_')
			{
				period[j] = filename[i];
				j++;
			}
			else
			{
				flag2 = true; //found the first "_"
				j = 0;
			}
		}
		else
		{
			if (flag3 == false)
			{
				if (filename[i] != '_')
				{
					reporttype[j] = filename[i];
					j++;
				}
				else
				{
					flag3 = true; //found the second "_"
					j = 0;
				}
			}
			else
			{
				if (flag4 == false)
				{
					if (filename[i] != '_')
					{
						location[j] = filename[i];
						j++;
					}
					else
					{
						flag4 = true; //found the third "_"
						j = 0;
					}
				}
				else
				{
					product[j] = filename[i];
					j++;
				}
			}
		}
	}
}
 
for (i = 0; i < product.Length; i++)
{
	temp[i] = product[(product.Length - 1) - i];
}
 
product = temp;
 
//repeat for others
Open in New Window
 
05.09.2008 at 10:12AM PDT, ID: 21534810
The problem with your code is that if you have a product name that includes a "_", then your code will assume the second half of it is something else.

Luke
 
05.09.2008 at 10:13AM PDT, ID: 21534826
This should be what your looking for.
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
82:
83:
84:
85:
86:
87:
88:
89:
90:
public String ReverseString(String ToReverse)
{
	char[] chars = ToReverse.ToCharArray();
	Array.Reverse(chars);
	return new String(chars);
}
 
public void Split()
{
	String ToParse = "CX3_CLARIION_ALL_cabrel_200803.doc";
 
	String Doc, Period, ReportType, Location, Product;
	Doc = Period = ReportType = Location = Product = String.Empty;
 
	String CurrentString = String.Empty;
 
	for (int i = ToParse.Length - 1; i > -1; i--)
	{
		Char currentChar = ToParse[i];
 
		if (Doc == String.Empty)
		{
			if (currentChar == '.')
			{
				Doc = CurrentString;
				CurrentString = String.Empty;
				continue;
			}
 
			CurrentString += currentChar.ToString();
			continue;
		}
 
		if (Period == String.Empty)
		{
			if (currentChar == '_')
			{
				Period = CurrentString;
				CurrentString = String.Empty;
				continue;
			}
 
			CurrentString += currentChar.ToString();
			continue;
		}
 
		if (ReportType == String.Empty)
		{
			if (currentChar == '_')
			{
				ReportType = CurrentString;
				CurrentString = String.Empty;
				continue;
			}
 
			CurrentString += currentChar.ToString();
			continue;
		}
 
		if (Location == String.Empty)
		{
			if (currentChar == '_')
			{
				Location = CurrentString;
				CurrentString = String.Empty;
				continue;
			}
 
			CurrentString += currentChar.ToString();
			continue;
		}
 
		if (Product == String.Empty)
		{
			CurrentString += currentChar.ToString();
 
			if (i == 0)
			{
				Product = CurrentString;
				CurrentString = String.Empty;
			}
		}
	}
 
	Product = ReverseString(Product);
	Location = ReverseString(Location);
	ReportType = ReverseString(ReportType);
	Period = ReverseString(Period);
	Doc = ReverseString(Doc);
}
Open in New Window
Accepted Solution
 
05.09.2008 at 11:58AM PDT, ID: 21535571
Ok, maybe I'm missing  something, but why not something like this?
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
            string tstString = "CX3_CLARIION_ALL_cabrel_200803.doc";
            string product;
            string location;
            string reportType;
            string period;
 
 
            string[] strArray = tstString.Split('.');
            string[] parseArray = strArray[0].Split('_');
 
            product = parseArray[0] + "_" + parseArray[1];
            location = parseArray[2];
            reportType = parseArray[3];
            period = parseArray[4];
Open in New Window
 
05.09.2008 at 12:04PM PDT, ID: 21535614
Ah, maybe it's because I misread the authors first comment.  Well, from the looks of it then, you're going to have to implement Luke or Fletchers approach.

 
 
20080236-EE-VQP-29 / EE_QW_2_20070628