<p>I'm sure this one is easy but I've tried a ton of variations and still cant match what I need.  The thing is being too greedy and I cant get it to stop being greedy.</p>

<p>Given the text:</p>

<pre><code>test=this=that=more text follows
</code></pre>

<p>I want to just select:</p>

<pre><code>test=
</code></pre>

<p>I've tried the following regex</p>

<pre><code>(\S+)=(\S.*)
(\S+)?=
[^=]{1}
...
</code></pre>

<p>Thanks all.</p>

here:
```
```
// matches "test=, test"
(\S+?)=

or

// matches "test=, test" too
(\S[^=]+)=
```
```
you should consider using the second version over the first. given your string
```
"test=this=that=more text follows"
```
, version 1 will match
```
test=this=that=
```
then continue parsing to the end of the string. it will then backtrack, and find
```
test=this=
```
, continue to backtrack, and find
```
test=
```
, continue to backtrack, and settle on
```
test=
```
as it's final answer.
version 2 will match
```
test=
```
then stop. you can see the efficiency gains in larger searches like multi-line or whole document matches.