Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

parse

Posted on 2012-04-11
2
Medium Priority
?
255 Views
Last Modified: 2012-04-11
Hi is it possible to use strtok to parse some data using a string as the first deliminator rather than using punctuation?


for example

data here string a b c d
more data here to disregard string e f g h

so that I only get a b c d e f g h?

Thanks
0
Comment
Question by:codey-06
2 Comments
 
LVL 86

Accepted Solution

by:
jkr earned 2000 total points
ID: 37835142
You can't do that with 'strtok()', since it uses single characters as delimiters, but 'strstr()' can help you here:

const char* get_text_afer_delimiter(cconst char* in, const char* delim) {

  char* p = strstr(in,delim);

  if (!p) return NULL; // 'delim' not found

  return p + strlen(delim);
}

// ...

char* p1 = "data here string a b c d";
char* p2 = "more data here to disregard string e f g h";

const char* p3 = get_text_afer_delimiter(p1, "string "); // include the blank, so the returned pointer points directly to "a b c d"

const char* p4 = get_text_afer_delimiter(p2, "string "); // include the blank, so the returned pointer points directly to "e f g h"

Open in new window

0
 

Author Closing Comment

by:codey-06
ID: 37835234
Thank you
0

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

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

Windows Script Host (WSH) has been part of Windows since Windows NT4. Windows Script Host provides architecture for building dynamic scripts that consist of a core object model, scripting hosts, and scripting engines. The key components of Window…
This article is meant to give a basic understanding of how to use R Sweave as a way to merge LaTeX and R code seamlessly into one presentable document.
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Suggested Courses

772 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