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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T07:55:02+00:00 2026-06-13T07:55:02+00:00

why \w pattern can’t match?and many pattern can’t work,eg:\s my os is Mac I

  • 0

why \w pattern can’t match?and many pattern can’t work,eg:\s

my os is Mac

I think maybe missing something;

that code only match char ‘w’,don’t sam.

thank your help

//
//  main.c
//  test
//
//  Created by SamPeng on 12-9-22.
//  Copyright (c) 2012年 SamPeng. All rights reserved.
//

#include <stdio.h>
#include <sys/types.h>
#include <regex.h>
#include <string.h>

int main(int argc, const char * argv[])
{
    int status,i;
    int cflags = REG_EXTENDED;
    regmatch_t pmatch[1];
    const size_t nmatch=1;
    regex_t reg;
    const char *pattern="\\w";
    char *buf = "sam@sampengw.org";

    regcomp(&reg, pattern, cflags);
    status = regexec(&reg, buf, nmatch, pmatch, 0);

    if(status == REG_NOMATCH)
        printf("No Match \n");
    else if(status == 0){
        printf("Match:\n");
        for (i=pmatch[0].rm_so; i<pmatch[0].rm_eo; ++i) {
            putchar(buf[i]);
        }
        printf("\n");
    }
    regfree(&reg);
    return 0;
}

complement:
yes,I know this work is POSIX Base reg,how change this? I wan’t use powerful regex

  • 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-13T07:55:04+00:00Added an answer on June 13, 2026 at 7:55 am

    The glib regex module supports POSIX extended regular expressions, which allow only a small subset of modern regular expression syntax, due to having been standardized in 1986. For shorthand classes like \w and \s, you want either the GNU extensions (available in Gnulib) or the PCRE library.

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

Sidebar

Related Questions

How can I match a pattern in regex that can contain anything (letters,numbers,...) but
So, An object that uses the singleton pattern can only have one instance. How
Is there a pattern that can handle recurring dimension in data warehouse? I've got
How can I implement the so called repository pattern that Rob Conery shows in
Can someone explain how the mediator pattern works with multiple instances. My code in
Can anyone suggest a pattern that can be used for writing a JavaScript API
I want to know if there is any pattern that can overcome this problem:
The pattern I'm looking for is this: TXT.*\.txt That pattern can occur multiple times
What pattern can I use to display errors on an MVC 2 view that
CouchDB employs a cool pattern that can be used in a multitude of other

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.