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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T10:48:23+00:00 2026-05-11T10:48:23+00:00

I am using posix c regex library(regcomp/regexec) on my search application. My application supports

  • 0

I am using posix c regex library(regcomp/regexec) on my search application. My application supports different languages including those that uses multi-byte characters. I’m encountering a problem when using word boundary metacharacter (\b). For single-byte strings, it works just fine, e.g:

‘\bpaper\b’ matches ‘paper’

However, if the regex and query strings are multi-byte, it doesn’t seem to work correctly, e.g:

‘\b紙張\b’ doesn’t match ‘紙張’

Am I missing something? Any help would be highly appreciated.

Requested Info:

  • Programming Language: C
  • Regex Library: GNU C (regex.h)

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. 2026-05-11T10:48:23+00:00Added an answer on May 11, 2026 at 10:48 am

    if the regex and query strings are multi-byte, it doesn’t seem to work correctly

    What is “multi-byte” in this context? A string encoded into UTF-8 bytes? A locale-specific multibyte encoding such as GB?

    If you’re not dealing with wide (Unicode) strings natively, you can’t expect any more support for non-ASCII characters than just detecting they’re there. POSIX regex doesn’t specify any character classes for bytes outside the ASCII range, so it doesn’t know that any of the bytes in ‘\xe7\xb4\x99’ (the UTF-8 representation of ‘紙’) could be considered word-letters; hence it sees no word boundaries.

    What constitutes a letter or a word in Unicode is a more involved question than simple ASCII regex can cope with. (And obviously, what constitutes a ‘word’ in Chinese is arguable in itself.) If all you want to detect is plain old spaces, you could do that explicitly:

    (\s|^)紙張(\s|$) 
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to extract a string from another using regex. I'm using the POSIX
Specifically, I'm using the Linux command: $ find . -regextype posix-extended -regex '<some regex>'
I'm using Posix Message Queues on Linux. Basically, I have multiple threads that receive
I built a client server application using posix shared memory and posix unnamed semaphores
I'm trying to build a client server application using POSIX shared memory and POSIX
What are the differences in using boost:thread, Posix Thread library and the new C++11
I'm using regex.h ( POSIX ) for regular expressions. Are there any selection methods
I'm trying to write some code using posix threads but I'm stuck from the
According to a number of tutorials (including Real World Haskell) one can, using ghci
I have question regarding shared memory segmentation in c using POSIX system calls. Is

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.