dev
dev

Reputation: 936

extracting values based on regex

I have a column which has urls, So below are the values of the column

https://www.example.com/jasja
https://www.example.com/jasdqw?new=exact

So what I want to extract is before the question mark and after the last slash

So here my output in the column should be

jasja
jasdqw

How can I get this using Regex Tried =REGEXEXTRACT(C2:C16, SPLIT()), but don't know how to use this

Any help is appreciated

Upvotes: 1

Views: 40

Answers (2)

z..
z..

Reputation: 13081

You could also try

=RegexExtract(A1,".*/(.*?)\?")

enter image description here

Upvotes: 1

Tim Biegeleisen
Tim Biegeleisen

Reputation: 522741

We can use REGEXEXTRACT with a capture group:

=REGEXEXTRACT(C2, "/([^/]+?)(?:\?|$)")

Here is a regex demo.

Upvotes: 1

Related Questions