Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

How to extract part of data

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

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 64

Expert Comment

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

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

Introduction Hi all and welcome to my first article on Experts Exchange. A while ago, someone asked me if i could do some tutorials on object oriented programming. I decided to do them on C#. Now you may ask me, why's that? Well, one of the re…
This article aims to explain the working of CircularLogArchiver. This tool was designed to solve the buildup of log file in cases where systems do not support circular logging or where circular logging is not enabled
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…
Suggested Courses

650 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