Solved

How to extract part of data

Posted on 2015-02-04
4
52 Views
Last Modified: 2015-02-09
How can I get 10 from this data pattern?

SAQ212QQQQ | Bagoong Factory | 10


Thanks,
0
Comment
Question by:JimiJ13
  • 2
4 Comments
 
LVL 29

Accepted Solution

by:
anarki_jimbel earned 250 total points
ID: 40590289
I'd split the string into an array and the last array item - your number.

        private void button2_Click(object sender, EventArgs e)
        {
            string pattern = @"SAQ212QQQQ | Bagoong Factory | 10";
            char[] chs = {'|'};

            string[] items = pattern.Split(chs);
           
            System.Diagnostics.Debug.WriteLine("This is your number: " + items[2]);
        }

Open in new window


Output:

This is your number:  10

Open in new window

0
 
LVL 62

Assisted Solution

by:Fernando Soto
Fernando Soto earned 250 total points
ID: 40590324
Hi  JimiJ13;

This will do what you want.

// Test Data
string data = "SAQ212QQQQ | Bagoong Factory | 10";
// The variable ten now has the value "10"
string ten = data.Substring(data.LastIndexOf('|') + 1).Trim();

Open in new window

0
 

Author Closing Comment

by:JimiJ13
ID: 40597860
Great solutions. I like both.
0
 
LVL 62

Expert Comment

by:Fernando Soto
ID: 40598349
Not a problem JimiJ13, glad to have been of assistance.
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Parse CSS value with RegEx 2 41
I need C# converted to VB.net 1 53
Hide Tab Page 3 19
fomat Json objects 6 18
This article describes a simple method to resize a control at runtime.  It includes ready-to-use source code and a complete sample demonstration application.  We'll also talk about C# Extension Methods. Introduction In one of my applications…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

758 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now