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

There are many functions (especially in the POSIX library) that return pointers to almost-necessarily
I'm trying to understand some of the basics of using POSIX pthreads. The kind
I really have a strange situation. I'm making a Linux multi-threaded C application using
I have a line-oriented text file (Unicode) that was created using CreateFile() and WriteFile().
Folks, in my application I'm using clock_gettime(CLOCK_MONOTONIC) in order to measure the delta time
I'm trying to write a chat server in C that allows communication between two
The OS I'm working on (IBM CNK, which is not Linux, but somewhat POSIX-compliant)
I am trying to display currently running process in Ubuntu. Right now I am
I have written the following code #include <iostream> #include <boost/asio.hpp> #include <boost/date_time/posix_time/posix_time.hpp> #include <boost/filesystem.hpp>
I'm writing an INI-like configuration file and I want to know the best way

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.