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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T01:56:07+00:00 2026-06-02T01:56:07+00:00

i need a regex that matches an expression ending with a word boundary, but

  • 0

i need a regex that matches an expression ending with a word boundary, but which does not consider the hyphen as a boundary.
i.e. get all expressions matched by

type ([a-z])\b

but do not match e.g.

type a-1

to rephrase: i want an equivalent of the word boundary operator \b which instead of using the word character class [A-Za-z0-9_], uses the extended class: [A-Za-z0-9_-]

  • 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-06-02T01:56:09+00:00Added an answer on June 2, 2026 at 1:56 am

    You can use a lookahead for this, the shortest would be to use a negative lookahead:

    type ([a-z])(?![\w-])
    

    (?![\w-]) would mean “fail the match if the next character is in \w or is a -“.

    Here is an option that uses a normal lookahead:

    type ([a-z])(?=[^\w-]|$)
    

    You can read (?=[^\w-]|$) as “only match if the next character is not in the character class [\w-], or this is the end of the string”.

    See it working: http://www.rubular.com/r/NHYhv72znm

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

Sidebar

Related Questions

I need a regular expression which matches: http://example.com/foo http://example.com/foo/ http://example.com/foo/bar but not: http://example.com/foobar Using
I need a regex that matches all strings ending in .cs, but if they
So, I need a regex expression to match a string that does not include
I need a regex that will match blahfooblah but not blahfoobarblah I want it
I need a regular expression that matches currency values similar to here: Regex for
I'm a regex newbie and need a single expression that: matches the an and
I need a regex that matches the following (the brackets indicate I want to
I need a regex that also matches Chinese, Greek, Russian, ... letters. What I
I need a regex that allows numbers and optional commas, but the entire length
I need to alter a RegEx pattern. I currently have this which matches all

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.