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 7704435
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T23:40:49+00:00 2026-05-31T23:40:49+00:00

Example: here is the string: blablabla123:550:404:487blablabla500:488:474:401blablablabla here is what I’m using: string reg =

  • 0

Example:

here is the string: "blablabla123:550:404:487blablabla500:488:474:401blablablabla"

here is what I’m using:

string reg = "(\\d{1,3}):(\\d{1,3}):(\\d{1,3}):(\\d{1,3})";

this obviously doesn’t work since it is looking for starting with the number,
and I also want to fetch all results, but I don’t know how to do that, even though I looked so much for it. :/

I want to have like 2 arrays with:

Array 1: should return [1] = “123”; [2] = “550”; [3] = “404”; [4] =
“487”;
Array 2: should return [1] = “500”; [2] = “488”; [3] = “474”;
[4] = “401”;

#include <regex>
#include <iostream>
#include <string>

#include <conio.h>
using namespace std;

typedef std::tr1::match_results<std::string::const_iterator> str_iterator;
int main () {
    str_iterator res;

string regex = "(\\d{1,3}):(\\d{1,3}):(\\d{1,3}):(\\d{1,3})";
string str = "blablabla123:550:404:487blablabla500:488:474:401blablablabla";
const std::tr1::regex pattern(regex.c_str());
bool valid = std::tr1::regex_match(str, res, pattern);
//res is gonna be an array with the match results
if(valid){
    printf("Matched with size of %d\n", res.size());
    printf("Result 1: %s",res[1]);
    printf("Result 2: %s",res[2]);
    printf("Result 3: %s",res[3]);
    printf("Result 4: %s",res[4]);
}else{
    printf("Not Matched");
}
_getch();
return 0;
}
  • 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-31T23:40:50+00:00Added an answer on May 31, 2026 at 11:40 pm

    regex_match will try to match the entire string. Obviously in your case, the result will be false (it won’t match).

    Try to use regex_search instead.

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

Sidebar

Related Questions

I have a string such as this: Land of gray [example]here is an example[/example]
For example, here is a string representing an expression: var str = 'total =
here is my example code: Public Class Parent Private _TestProperty As String Private WithEvents
Here's the problem. I ,for example,have a string 2500.Its converted from byte array into
The fictional example here. Suppose I designed a class named IODevice. This class already
This problem is not readily reproducible in a simple example here but was wondering
What does this do? I find the example here, but other than what it
For example: Here's a simple class. class Hero { public string faction; public string
Background: Here the goal is to do some basic commands in powershell using select-string.
Following the example here On deploying a sample resource using the Grizzly container. It

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.