I am trying to determine the correct RegEx syntax to perform the following. I have line in a file in which I want to match every character before the first occurrence of white space.

so for example in the line:

123abc xyz foo bar

it is unclear to me why the following:

^.*\s

is matching up to the b in the word bar:

123abc xyz foo

It appears to me that the \s is greedy, however I am not certain how I can make it not greedy and just match 123abc I have tried various forms of this regex in an attempt to make it non-greedy ^.*\s? or something like this, however I have been unsuccessful. Thank you in advance

Edit
Report