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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T03:26:09+00:00 2026-05-25T03:26:09+00:00

From regular-expressions.info : \b\w+(?<!s)\b . This is definitely not the same as \b\w+[^s]\b .

  • 0

From regular-expressions.info:

\b\w+(?<!s)\b. This is definitely not the same as \b\w+[^s]\b. When applied to Jon's, the former will match Jon and the latter Jon' (including the apostrophe). I will leave it up to you to figure out why. (Hint: \b matches between the apostrophe and the s). The latter will also not match single-letter words like “a” or “I”.

Can you explain why ?

Also, can you make clear what exacly \b does, and why it matches between the apostrophe and the s ?

  • 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-25T03:26:10+00:00Added an answer on May 25, 2026 at 3:26 am

    \b is a zero-width assertion that means word boundary. These character positions (taken from that link) are considered word boundaries:

    • Before the first character in the string, if the first character is a word character.
    • After the last character in the string, if the last character is a word character.
    • Between two characters in the string, where one is a word character and the other is not a word character.

    Word characters are of course any \w. s is a word character, but ' is not. In the above example, the area between the ' and the s is a word boundary.

    The string "Jon's" looks like this if I highlight the anchors and boundaries (the first and last \bs occur in the same positions as ^ and $): ^Jon\b'\bs$

    The negative lookbehind assertion (?<!s)\b means it will only match a word boundary if it’s not preceded by the letter s (i.e. the last word character is not an s). So it looks for a word boundary under a certain condition.

    Therefore the first regex works like this:

    1. \b\w+ matches the first three letters J o n.

    2. There’s actually another word boundary between n and ' as shown above, so (?<!s)\b matches this word boundary because it’s preceded by an n, not an s.

    3. Since the end of the pattern has been reached, the resultant match is Jon.

    The complementary character class [^s]\b means it will match any character that is not the letter s, followed by a word boundary. Unlike the above, this looks for one character followed by a word boundary.

    Therefore the second regex works like this:

    1. \b\w+ matches the first three letters J o n.

    2. Since the ' is not the letter s (it fulfills the character class [^s]), and it’s followed by a word boundary (between ' and s), it’s matched.

    3. Since the end of the pattern has been reached, the resultant match is Jon'. The letter s is not matched because the word boundary before it has already been matched.

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

Sidebar

Related Questions

I need help extracting the value of a wildcard from a Regular Expressions match.
I'm used to regular expressions from Perl. Does anybody know why this doesn't work
I'll preface this question by mentioning that while I'm far from a regular expressions
I generally stay away from regular expressions because I seldom find a good use
How do I pull out the filename from a full path using regular expressions
I use RegexBuddy while working with regular expressions. From its library I copied the
I'm reading a regular expression from a configuration file, which may or may not
How can I create a regular expression that will grab delimited text from a
I need a model for finding all of the regular expressions that would match
I want to extract text from a column using regular expressions in Oracle 11g.

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.