Golden
Golden

Reputation: 417

Regex - Extract string between two expressions, get only last apperance

Trying to create a regex query that will only return the bolded string:

' Mozilla/5.0 (Linux; U; Android 4.2.2; en-us; A2003 Build/JDQ39) AppleWebKit/534.30 (KHTML, like Gecko) Version/4.0 Mobile Safari/534.30 ',

I tried a few ways - got to this option: (?<=;)(.* Build)

But it returns the following string:

U; Android 4.2.2; en-us; A2003 Build

Suggestions?

Upvotes: 1

Views: 48

Answers (1)

CinCout
CinCout

Reputation: 9619

You don't really need a lookbehind. Do this:

[^;]* Build

Demo

Match everything other than ; followed by a space and "Build".

If the spaces can be of any type and more than one, do this:

[^;]*\s+Build

Upvotes: 1

Related Questions