Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6221033
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T08:03:50+00:00 2026-05-24T08:03:50+00:00

The two-line string to parse is: 00:02.0 VGA compatible controller [0300]: Intel Corporation 82945G/GZ

  • 0

The two-line string to parse is:

00:02.0 VGA compatible controller [0300]: Intel Corporation 82945G/GZ Integrated Graphics Controller [8086:2772] (rev 02)
00:02.1 Display controller [0380]: Intel Corporation 82945G/GZ Integrated Graphics Controller [8086:2776] (rev 02)

to get these strings out:

(from 1st line)

  • VGA compatible controller
  • Intel Corporation 82945G/GZ Integrated Graphics Controller
  • [8086:2772]

(from 2nd line)

  • Display controller
  • Intel Corporation 82945G/GZ Integrated Graphics Controller
  • [8086:2776]

Now my starting code is:

NSScanner *scn = [NSScanner scannerWithString:strtoparse];
NSString *devtype;      
while ([scn isAtEnd] == NO)
    {
       if( [scn scanUpToCharactersFromSet:[NSCharacterSet whitespaceCharacterSet] intoString:NULL] &&
        [scn scanUpToString:@"[" intoString:&devtype]);
    }

and this aint working. I cant even understand the scanner from the docs. So can someone post working code?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T08:03:52+00:00Added an answer on May 24, 2026 at 8:03 am

    Quick snippet:

    NSString *theString = @"00:02.0 VGA compatible controller [0300]: Intel Corporation 82945G/GZ Integrated Graphics Controller [8086:2772] (rev 02)\n00:02.1 Display controller [0380]: Intel Corporation 82945G/GZ Integrated Graphics Controller [8086:2776] (rev 02)";
    
    NSScanner *theScanner = [NSScanner scannerWithString:theString];
    
    NSCharacterSet *space = [NSCharacterSet characterSetWithCharactersInString:@" "];
    NSCharacterSet *bracket = [NSCharacterSet characterSetWithCharactersInString:@"["];
    NSCharacterSet *linebreak = [NSCharacterSet newlineCharacterSet];
    
    NSString *type;
    NSString *name;
    NSString *number;
    
    while (![theScanner isAtEnd]) 
    {
        [theScanner scanUpToCharactersFromSet:space intoString:nil] ;
        [theScanner scanUpToCharactersFromSet:bracket intoString:&type]; 
        [theScanner scanUpToCharactersFromSet:space intoString:nil] ;
        [theScanner scanUpToCharactersFromSet:bracket intoString:&name]; 
        [theScanner scanUpToCharactersFromSet:space intoString:&number]; 
        [theScanner scanUpToCharactersFromSet:linebreak intoString:nil] ;
    
        NSLog(type);
        NSLog(name);
        NSLog(number);
    }
    

    Output:

    VGA compatible controller 
    Intel Corporation 82945G/GZ Integrated Graphics Controller 
    [8086:2772]
    Display controller 
    Intel Corporation 82945G/GZ Integrated Graphics Controller 
    [8086:2776]
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a file named file with three lines: line one line two line
I have one line (two point (x,y) (x1,y1)) and a rectangle with focus point
I have two points (a line segment) and a rectangle. I would like to
I want to remove a line connecting two labels. Actually, I want to remove
I'm looking for a simple line or two of code that will grab an
I have a file in which each line contains two numbers. The problem is
I'm trying to use Unix cut to remove the first two fields per line.
I want to have two items on the same line using float: left for
Say I have two files where there is one number per line File 1
How can I execute two consecutive commands on the command line with the help

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.