Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Excel: Remove everything after ? in a url

I already searched for formulas or add ins online but can't seem to find any formula for this.

I was wondering if I can remove everything after a question mark in a URL?

http://www.site.com/index.php?98943j%klr

to

http://www.site.com/index.php

Thanks!

like image 423
user3075601 Avatar asked Dec 21 '13 09:12

user3075601


2 Answers

Try

=IF(LEN(SUBSTITUTE(A1,"?",""))=LEN(A1),A1,LEFT(A1,FIND("?",A1)-1))

to

  • Cater for the ? not appearing in A1 without raising an error
  • Properly truncating the string to http://www.site.com/index.php .... your accepted answer doesnt adjust for the position of ? and it will return http://www.site.com/index.php?
like image 79
brettdj Avatar answered Sep 20 '22 23:09

brettdj


If you want to return another hyperlink, but only cosisting of everything before the question mark, you could use the following formula, having you URL in cell A1.

=HYPERLINK(LEFT(A1,FIND("?",A1,1)-1))
like image 20
Netloh Avatar answered Sep 16 '22 23:09

Netloh