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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T03:26:06+00:00 2026-05-27T03:26:06+00:00

I have witten a simple c program as follows: #include <stdio.h> #include <regex.h> int

  • 0

I have witten a simple c program as follows:

#include <stdio.h>
#include <regex.h>

int main(int argc, char* argv[])
{
    regex_t re;
    char *pattern = "\\d{3}([a-zA-Z]+).(\\d{2}|N/A)\\s\\1"; // use \d, but wouldn't match
    const char *target = "123Hello N/A Hello";

    regcomp(&re, pattern, REG_EXTENDED|REG_NOSUB);

    int ret = regexec(&re, target, (size_t) 0, NULL, 0);
    if(ret == REG_NOMATCH) {
        printf("\n%s\n does not match \n%s\n", target, pattern);
    }

    pattern = "[0-9]{3}([a-zA-Z]+).([0-9]{2}|N/A)\\s\\1"; // changes to [0-9], now OK

    regcomp(&re, pattern, REG_EXTENDED|REG_NOSUB);

    ret = regexec(&re, target, (size_t) 0, NULL, 0);
    if(ret == REG_NOMATCH) {
        printf("\n%s\n does not match \n%s\n", target, pattern);
    }

    regfree(&re);
    return 0;
}

I have read the POSIX regular expressions standard on Wikipedia, I haven’t found any evidence for that whether the POSIX stand suports the \d metacharacter.

Or there is a subtle mistake in my 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-27T03:26:06+00:00Added an answer on May 27, 2026 at 3:26 am

    According to this, POSIX regular expressions do not support the \d shorthand (and neither do they support \w or \s).

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

Sidebar

Related Questions

I have written a simple Hello World program. #include <stdio.h> int main() { printf(Hello
I have written a simple program that does autocorrelation as follows...I've used pgi accelerator
I have written a simple C++ shell program to parse large XML files and
I have written this simple C program that changes the rotation file name. Eg:
I have written a simple python program l=[1,2,3,0,0,1] for i in range(0,len(l)): if l[i]==0:
Studing STL I have written a a simple program to test functors and modifiers.
I have written a simple server - client program with Swing interface using singleton
I have a problem running a simple Hello-world program in C++ on my Windows
I have written a simple program that pings three sites and then reacts to
I have written a simple network program on java using sockets. Program has a

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.