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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T14:35:46+00:00 2026-05-12T14:35:46+00:00

On my OS X 10.5.8 machine, using the regcomp and regexec C functions to

  • 0

On my OS X 10.5.8 machine, using the regcomp and regexec C functions to match the extended regex “(()|abc)xyz”, I find a match for the string “abcxyz” but only from offset 3 to offset 6. My expectation was that the entire string would be matched and that I would see a submatch for the initial “abc” part of the string.

When I try the same pattern and text with awk on the same machine, it shows a match for the entire string as I would expect.

I expect that my limited experience with regular expressions may be the problem. Can somebody explain what is going on? Is my regular expression valid? If so, why doesn’t it match the entire string?

I understand that “((abc){0,1})xyz” could be used as an alternative, but the pattern of interest is being automatically generated from another pattern format and eliminating instances of “()” is extra work I’d like to avoid if possible.

For reference, the flags I’m passing to regcomp consist only of REG_EXTENDED. I pass an empty set of flags (0) to regexec.

  • 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-12T14:35:46+00:00Added an answer on May 12, 2026 at 2:35 pm

    The POSIX standard says:

    9.4.3 ERE Special Characters

    An ERE special character has special properties in certain contexts. Outside those contexts, or when preceded by a <backslash>, such a character shall be an ERE that matches the special character itself. The extended regular expression special characters and the contexts in which they shall have their special meaning are as follows:

    .[\(

    The <period>, <left-square-bracket>, <backslash>, and <left-parenthesis> shall be special except when used in a bracket expression (see RE Bracket Expression ). Outside a bracket expression, a <left-parenthesis> immediately followed by a <right-parenthesis> produces undefined results.

    What you are seeing is the result of invoking undefined behaviour – anything goes.

    If you want reliable, portable results, you will have to eliminate the empty ‘()‘ notations.

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

Sidebar

Ask A Question

Stats

  • Questions 287k
  • Answers 288k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer From: http://code.google.com/p/k9mail/source/browse/k9mail/trunk/res/layout/account_setup_basics.xml?r=1314 <RelativeLayout android:layout_marginTop="-45dip" android:padding="0dip" android:layout_alignParentBottom="true" android:gravity="bottom|right" android:background="@android:drawable/bottom_bar" android:layout_height="fill_parent" android:layout_width="fill_parent">… May 13, 2026 at 5:15 pm
  • Editorial Team
    Editorial Team added an answer Apache Velocity May 13, 2026 at 5:15 pm
  • Editorial Team
    Editorial Team added an answer Because you should be using the octal literal 0777, not… May 13, 2026 at 5:15 pm

Related Questions

I'm struggling with a Mac OS X 10.5.8 that I've started using recently for
I am starting to develop a site which basically acts as WordPress MU, in
I have a set of Test::Unit tests for a Rails application. It was developed
After trying to install ruby19 on my machine (PPC, Mac OSX 10.5.7) using the

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.