alt
alt

Reputation: 13927

Regex that matches between two strings, including the first string

Let's say I have a string:

var n = 10

I'd like a regex which matches the following portion:

var n

I've tried:

var(.*?)=

But that only matches:

n

Upvotes: 1

Views: 51

Answers (1)

Ibrahim Najjar
Ibrahim Najjar

Reputation: 19423

Why not wrap the whole thing with parentheses like this:

(var.*?)=

Upvotes: 3

Related Questions