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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T00:58:31+00:00 2026-06-05T00:58:31+00:00

I need a rather complicated regular expression that will select words with one space

  • 0

I need a rather complicated regular expression that will select words with one space between them and that can include the ‘-‘ symbol in them, it should not however select continuous whitespace.

'KENEDY JOHN G JR E'                  'example'                 'D-54'

I have tried the following regular expression:

\'([\s\w-]+)\'

but it selects continuous whitespace which I don’t want it to do.

I want the expression to select

'KENEDY JOHN G JR E'
'example'
'D-54'
  • 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-05T00:58:33+00:00Added an answer on June 5, 2026 at 12:58 am

    Perhaps,

    \'([\w-]+(?:\s[\w-]+)*)\'
    

    ?

    EDIT

    If leading/trailing dashes (on the word boundaries) are not allowed, this should read:

    /\'(\w+(?:[\s-]\w+)*)\'/
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to unpack binary data that is encoded rather exotically: a 32 bit
I have a number rather large, complex xml documents that I need to loop
I am trying to build a lambda expression that will be combined with others
I have a jqGrid (pared-down example below) where I need rather complicated validation to
I'm working on a rather complicated site. We have an update panel that contains
I have one main view with an associated controller. I have some rather complicated
I work with a rather complicated web UI that includes a lot of javascript,
I have a rather complicated scenario that I have never really had to deal
I need to add this kind of feature to a site that will preview
I have a rather complicated issue that I am trying to solve in PHP

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.