# Preg match first word? \*Brain Freeze..\*

**URL:** <https://forum.kirupa.com/t/preg-match-first-word-brain-freeze/267334>\
**Category:** programming\
**Created:** [July 30, 2008, 8:58pm UTC](https://forum.kirupa.com/t/preg-match-first-word-brain-freeze/267334 "2008-07-30T20:58:39Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![DesignerMichael](https://avatars.discourse-cdn.com/v4/letter/d/898d66/32.png) [@DesignerMichael](https://forum.kirupa.com/u/DesignerMichael)\
**Post date:** [July 30, 2008, 8:58pm UTC](https://forum.kirupa.com/t/preg-match-first-word-brain-freeze/267334/1 "2008-07-30T20:58:39Z")

</div>

Man… Having a brain freeze… Forgot how to preg match. What I have are user names in multiple formats… “John”, “John Doe”, “James John Doe”. I just want the first name.

So if I use preg\_match\_all… Would it be something like… /^{abc}/  
Then the first index 0 would be the first word.

I have been working too much…
