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

  • SEARCH
  • Home
  • 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 8013619
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T19:40:45+00:00 2026-06-04T19:40:45+00:00

How can I tokenize strings like this in c: char str1[] = property ::

  • 0

How can I tokenize strings like this in c:

char str1[] = " property :: content | label ";
char str2[] = "property::content";
char str3[] = "content";

[edit]

I have tried the folowwing:

char str[] = " property :: content | label ";
char *property, *content, *label;

property = strtok(str, "::");
content = strtok(NULL, "|");
label = strtok(NULL, "|");

printf ("%s %s %s\n", property, content, label);

but it splits strings according to a char so it would work for the pipe character used to delimit labels. However the “::” delimiter is a string, not a char. I don’t know how to deal with it.

[edit 2]

I also have this code:

char sentence [] = "property :: content | label";
char property [30];
char content [30];
char label [30];

sscanf (sentence, "%s :: %s | %s", property, content, label);
printf ("<span property=\"%s\" content=\"%s\">%s</span>\n", property, content, label);

I’m just wondering how I can dynamically set the size of each char array…

Thanks.

  • 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-06-04T19:40:46+00:00Added an answer on June 4, 2026 at 7:40 pm

    What you need is a basic lexer

    The best way to know it is to pick up a compiler book and read on that.

    In short, you would need a bunch of regular expressions and start matching your strings against the regular expressions until you find the biggest matching one with its corresponding dfa in a final state.

    Alternatively, if every token is separated by space, you can simply use strtok and strcmp to distinguish between special words (such as ::) and the rest of the input.

    After the lexical analysis is done, you’d need a parser. I don’t know your application, so your parser could turn out to be really simple, but otherwise, this answer might help you kick off.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have string like this: command . / * or any other char like
this question feels like it would have been asked already, but I've not found
Let's say I have a domain object that looks like this: @Entity @Indexed public
I have string like this /c SomeText\MoreText Some Text\More Text\Lol SomeText I want to
I want to tokenize a string like this String line = a=b c='123 456'
I have a string that occurs in this format: .word 40 I would like
This should tokenize space delimited fields in the string str: float values[2*linesnum(str, length)]; char
e.g. if you have code that does something like this somewhere in your codebase:
Can someone please explain why this doesn't work? MyClass myClass1 = new MyClass(); object
Can someone help me with this scenario? *There is a button, which when tapped,

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.