?
Solved

How to extract part of data

Posted on 2015-02-04
4
Medium Priority
?
59 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 1000 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 1000 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

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…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
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.
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
Suggested Courses
Course of the Month12 days, 22 hours left to enroll

777 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