string help in asp.net

I've got 3 sets of radio buttons on an asp.net page and need to parse out the string that is returned when a user makes a selection.

8700  $199.99  12
7105  $99.99   12
7290  $49.99   12

The value for each looks like: 8700199.9912
-------------------------------------------------

code:
string modelpricemonth;
string variableModel; // = 8700
string variablePrice; // = 199.99
string variableMonth; // = 12

modelpricemonth = ModelType.SelectedItem.Value;
LabelSummary.Text = modelpricemonth; //8700199.9912

LabelModel.text = variableModel;
LabelPrice.text = "$" + variablePrice;
LabelMonths.text = variableMonth;
-----------------------------------------------------

How do I get this result?

LabelModel.Text = 8700
LabelPrice.Text = $199.99
LabelMonths.Text = 12

thanks
fwstealAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Mike TomlinsonMiddle School Assistant TeacherCommented:
Will the model ALWAYS be four digits?

Will there ALWAYS be two digits after the decimal place?
0
gbzhhuCommented:
excellent questions idle maind. can't helkp without knowing these
0
fwstealAuthor Commented:
yes and yes, those formats will always be the same
0
Cloud Class® Course: CompTIA Healthcare IT Tech

This course will help prep you to earn the CompTIA Healthcare IT Technician certification showing that you have the knowledge and skills needed to succeed in installing, managing, and troubleshooting IT systems in medical and clinical settings.

fwstealAuthor Commented:
constant values; sorry new to c#
0
Fernando SotoRetiredCommented:
Hi fwsteal;

Here is a sample code that will do what you want using Regular Expression.

using System.Text.RegularExpressions;

      string data = "8700199.9912";
      string Model = "";
      string Price = "";
      string Month = "";
      Match m = Regex.Match(data,
            @"(?<Model>\d{4})(?<Price>\d+\.\d\d)(?<Month>\d+)");
      if( m.Success )
      {
            Model = m.Groups["Model"].Value;
            Price = m.Groups["Price"].Value;
            Month = m.Groups["Month"].Value;
                        
            MessageBox.Show("Model = " + Model + " Price = $" + Price +
                  " Month = " + Month);
      }


Fernando
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Mike TomlinsonMiddle School Assistant TeacherCommented:
You could also do...

            string modelpricemonth = "8700199.9912";
            int period = modelpricemonth.IndexOf(".");
            string variableModel = modelpricemonth.Substring(0,4);            
            string variablePrice = modelpricemonth.Substring(4, period - 4 + 3);
            string variableMonth = modelpricemonth.Substring(period + 3);
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
C#

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.