'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



Solution 1:[1]

We can use REGEXEXTRACT with a capture group:

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

Here is a regex demo.

Solution 2:[2]

You could also try

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

enter image description here

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Tim Biegeleisen
Solution 2 ztiaa