Home > OS >  extracting values based on regex
extracting values based on regex

Time:03-28

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

CodePudding user response:

We can use REGEXEXTRACT with a capture group:

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

Here is a regex enter image description here

  • Related