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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T10:59:31+00:00 2026-05-28T10:59:31+00:00

I have (hacked) this regex this far which matches any words between hyphens and

  • 0

I have (hacked) this regex this far which matches any words between hyphens and separates them, leaving out articles that are 1 character. The reason I need these words separate is that Blogger manages to stop the url at 39 characters AND doesn’t break any words. This works so far:

^((([a-zA-Z0-9]{2,39})-)+)(?:([a-zA-Z0-9]{1})-)((([a-zA-Z0-9]{2,39})-)+){2,39}$

Tested against /wishing-you-a-very-merry-christmas-and-a-happy-new-year.html
Matches: wishing-you-a-very-merry-christmas-and-
Replacement String: $1 (not working!!) it results in:

How do I get the 1-letter articles to NOT print in the results regex? And how do I test for and remove the last - in my results?

  • 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-28T10:59:31+00:00Added an answer on May 28, 2026 at 10:59 am

    You cannot build this with one regex.

    The part with max 39 characters in length and not ending with - is no problem.

    ^\/?([\w-]{3,39})(?<!-).*
    

    See it on Regexr

    (?<!-) is a lookbehind assertion that ensures that the string is not ending with a hyphen.

    But you cannot remove at the same time substrings with the length of 1.

    On its own this is also no problem

    (?<=[/-]|^)[^-]-|-[^-](?=[-./]|$)
    

    See it here on Regexr

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

Sidebar

Related Questions

I have this chunk of javascript that's kind of hacked around from http://www.developphp.com/view.php?tid=1248 and
I have a running website on wordpress which has been hacked, some file were
have written this little class, which generates a UUID every time an object of
Have deployed numerous report parts which reference the same view however one of them
I have hacked on a branch for a while, and this branch won't be
The light box pops up, but doesn't load the image. I have hacked this
How I love regex! I have a string which will be a mangled form
I have an old joomla installation which was hacked. All I know for now
I have a client who's wordpress sites have gotten hacked twice by iframe scammers.
I have a crashed/hacked Joomla installation (Files and Folders only) Database has NOT been

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.