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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T18:13:33+00:00 2026-06-11T18:13:33+00:00

I have a string resource = /Music/1 the string can take multiple numeric values

  • 0

I have a string
resource = “/Music/1”
the string can take multiple numeric values after “/Music/” . I new to regular expression stuff . I tried following code

#include <iostream>

#include<boost/regex.hpp>

int main()
{
    std::string resource = "/Music/123";

    const char * pattern = "\\d+";

    boost::regex re(pattern);

    boost::sregex_iterator it(resource.begin(), resource.end(), re);
    boost::sregex_iterator end;

    for( ; it != end; ++it)
    {
        std::cout<< it->str() <<"\n";
    }
    return 0;
}

vickey@tb:~/trash/boost$ g++ idExtraction.cpp  -lboost_regex
vickey@tb:~/trash/boost$ ./a.out 
123

works fine . But even when the string happens to be something like “/Music23/123” it give me a value 23 before 123. When I use the pattern “/\d+” it would give results event when the string is /23/Music/123. What I want to do is extract the only number after “/Music/” .

  • 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-11T18:13:34+00:00Added an answer on June 11, 2026 at 6:13 pm

    I think part of the problem is that you haven’t defined very well (at least to us) what it is you are trying to match. I’m going to take some guesses. Perhaps one will meet your needs.

    • The number at the end of your input string. For example “/a/b/34“. Use regex "\\d+$".
    • A path element that is entirely numeric. For example “/a/b/12/c” or “/a/b/34” but not “/a/b56/d”. Use regex "(?:^|/)(\\d+)(?:/|$)" and get captured group [1]. You might do the same thing with lookahead and lookbehind, perhaps with "(?<=^|/)\\d+(?=/|$)".
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have just started using flexigrid and wanted to use the resource string to
Is it possible to have multiple resource bundles in spring mvc? I want to
I have an extension method for getting a string from resource file in asp.net
I have a string resource called foo. It may be a simple string... or
I want to have a string resource, which contains a hyperlink in it. I
I want to know that I have the string.xml Resource file which contains status
Possible Duplicate: Dynamic Resource Loading Android In Android, I can load a string from
I have created a String resource in Android: <string name=package_Name>com.blue.MonkeyTech</string> I want to reference
I have two domain models: class Resource{ String name static mapping = { sort
I have to concatenate these two strings from my resource/value files: <string name=Toast_Memory_GameWon_part1>you found

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.