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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T03:38:36+00:00 2026-05-31T03:38:36+00:00

Why is this positive lookahead not matching the text in bold ? (not .

  • 0

Why is this positive lookahead not matching the text in bold ? (not . and not ->)

[_a-z0-9]+(?=\.|->)[_a-z0-9]+

hints6.ai_flags = 0; // comment hints.ai_flags
hints6.ai_family = AF_UNSPEC;
int newsocket = socket(result->ai_family, result->ai_socktype, result->ai_protocol);

  • 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-31T03:38:37+00:00Added an answer on May 31, 2026 at 3:38 am

    first, you need to escape the . (. matches ‘anything’, you want \. to match “.”) [weird – someone edited the question to fix that]

    second, a lookahead looks ahead – it doesn’t consume anything. so, even if you escape the ., [_a-z0-9]+(?=\.|->) is only consuming “hints6” (and then, looking ahead, confirming that the next character will be “.”). after that, [_a-z0-9]+ fails to match the “.”.

    i don’t really understand what you are trying to do. as far as i can see, [_a-z0-9]+(?:\.|->)[_a-z0-9]+ would do what you want, without any lookahead ((?:...) is a grouping that doesn’t bind to results).

    in general, you don’t need lookahead much, because you can just match. it’s used mainly when you want to match a group, but for some (strange) reason need to check a specific case beforehand.

    [edit:] if you just want to capture the two words then use ([_a-z0-9]+)(?:\.|->)([_a-z0-9]+) (note that will capture two groups, one for each word).

    [edit2:] if this is for a syntax highlighter then i think you could go with something that highlights either word. it’s easier to show than explain:

    (?:[_a-z0-9]+(?=(?:\.|->)[_a-z0-9]+)|(?<=[_a-z0-9]+(?:\.|->))[_a-z0-9]+)
    

    that will highlight either “a word followed by .word” or “a word preceded by word.”, which will highlight both words without highlighting the dot. they are two separate matches, but the syntax highlighter doesn’t care about that (i assume).

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

Sidebar

Related Questions

You can convert a negative number to positive like this: int myInt = System.Math.Abs(-5);
This code works on simulator but not on device. I am positive this has
I had posted this earlier on Stack Overflow, but couldn't get a positive result.
So Python has positive and negative infinity: float(inf), float(-inf) This just seems like the
I'm almost positive this has been answered already; however, unable to find it since
I'm positive that this guide existed, but my Google skills seem to be broken
I have this problem: A positive integer is called a palindrome if its representation
I've found the way to do this is using negative - lookahead and /
After I do a positive lookahead in eclipse 3.5, I am unable to do
I'm pretty much positive about this, but just to be on the safe side:

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.