Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

regular expression: match any word until first space

Tags:

regex

I have the following line:

hshd    household   8/29/2007   LB

I want to match anything that comes before the first space (whitespace). So, in this case, I want to get back

hshd
like image 653
Drake Avatar asked Sep 29 '22 02:09

Drake


2 Answers

([^\s]+)

works

like image 419
SilentGhost Avatar answered Oct 17 '22 03:10

SilentGhost


This should do it:

^\S*
like image 66
Jeremy Stein Avatar answered Oct 17 '22 04:10

Jeremy Stein