regex - Regular expression for selecting single spaced phrases but not whitespace -


i need rather complicated regular expression select words 1 space between them , can include '-' symbol in them, should not select continuous whitespace.

'kenedy john g jr e'                  'example'                 'd-54' 

i have tried following regular expression:

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

but selects continuous whitespace don't want do.

i want expression select

'kenedy john g jr e' 'example' 'd-54' 

perhaps,

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

?

edit

if leading/trailing dashes (on word boundaries) not allowed, should read:

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

Comments

Popular posts from this blog

java - Play! framework 2.0: How to display multiple image? -

gmail - Is there any documentation for read-only access to the Google Contacts API? -

php - Controller/JToolBar not working in Joomla 2.5 -