Remove or Replace Everything After Character Google Sheets

I was creating affiliate links but the urls that I was working with had tracking code added to the end with javascript. There were 40 links that looked like this:

http://www.headlineshirts.net/sharkula-t-shirt.html#.VmQs-Yl96Uk

I didn’t want to delete the code manually even though it wouldn’t take that much time. I wanted to remove the # and everything after it.

I was able to use this function in Google Sheets.

#.*

Select the calls you want to edit and use the Find and Replace feature and don’t forget to check “Search using regular expressions.”

Remove everything after character

You can see that I left the Replace with area empty. That is because I just wanted to remove text. But you could change the text this way if you wanted.

24 Comments

  1. Holy smokes this is awesome. Exactly what I was looking for. thank you so much!

  2. Thanks! I had a little trouble searching for ‘?’. Placed brackets around it like this [?].* and it worked. Saved me a lot of time.

    1. Great. I had a similar issue. I think I did a search and replace with the ? to a # or something like that.

  3. It’s not working for me. I want to get rid of everything after a comma and space “, “. I’m putting in {, *} and it’s only removing the comma and the space.

    What am I doing wrong?

    1. You might have forgotten the period.
      Try
      , .*
      instead of
      , *

  4. Just saved me the manual effort of removign parameters on a list of 58K URLs. THANK YOU!

  5. Thank you! This is awesome. I used same method to remove characters before a comma ( .*, ) in ~400 records. Thanks again!

  6. Hmmm. I’t snot working for me. I’m trying to remove everything after a colon. For example,
    “Auto & Transport:Auto Insurance”

    Doing :.* and [:].* and neither is doing anything.

    1. I have had some trouble depending on the character I am dealing with too. One possible solution is to do a search-replace on the colon (e.g. change : to #) and then try again using the idea above. I hope that helps.

  7. Thanks a lot! That worked. I wanted to remove everything after a “:” to clean up my SKUs for my webshop, so I just did a ctrl+H to get to the “find and replace” added :.* and it worked 🙂 Im a happy camper!

    Regards

    Bruno

Leave a Reply

Your email address will not be published. Required fields are marked *