Solved

How to extract part of data

Posted on 2015-02-04
4
58 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 30

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 63

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 63

Expert Comment

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

Featured Post

Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

We all know that functional code is the leg that any good program stands on when it comes right down to it, however, if your program lacks a good user interface your product may not have the appeal needed to keep your customers happy. This issue can…
This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.

717 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