2 Replies - 840 Views - Last Post: 21 April 2009 - 11:41 AM Rate Topic: -----

#1 Dumpen   User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 56
  • Joined: 21-March 08

Split weird string

Posted 21 April 2009 - 11:12 AM

Hello

I have a weird string I need to split up into pieces

How would you split this string up into an array(List)?
%Lastname&Firstname Middlename					 TRIGE CENTERVEJ 50 ST TH


What I want is:
Firstname, middlename and lastname

My problem comes after middlename since its only spaces

Any suggestions?

And no I cant change "the weird string" :)

This post has been edited by Dumpen: 21 April 2009 - 11:28 AM


Is This A Good Question/Topic? 0
  • +

Replies To: Split weird string

#2 lesPaul456   User is offline

  • D.I.C Addict
  • member icon

Reputation: 175
  • View blog
  • Posts: 729
  • Joined: 16-April 09

Re: Split weird string

Posted 21 April 2009 - 11:29 AM

You could try using regular expressions.

Just add this to your namespaces:
 using System.Text.RegularExpressions


Then create a pattern of keywords:
 Regex keyWords = new Regex("firstname|middlename|lastname", RegexOptions.IgnoreCase);


And then loop through each match found using a foreach loop.

This post has been edited by lesPaul456: 21 April 2009 - 11:29 AM

Was This Post Helpful? 1
  • +
  • -

#3 lesPaul456   User is offline

  • D.I.C Addict
  • member icon

Reputation: 175
  • View blog
  • Posts: 729
  • Joined: 16-April 09

Re: Split weird string

Posted 21 April 2009 - 11:41 AM

Post back if you need an example.
Was This Post Helpful? 1
  • +
  • -

Page 1 of 1