Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

replace everything after a character in Google spreadsheet

I did some searching and in openoffice and excel it looks like you can simply add an * at the beginning or end of a character to delete everything before and after it, but in Google spreadsheet this isn't working. Does it support this feature? So if I have:

keyword USD  0078945jg .12 N N 5748 8

And I want to remove USD and everything after it what do I use? I have tried:

USD* and (USD*) with regular expressions checked

But it doesn't work. Any ideas?

like image 957
conlustro Avatar asked Aug 19 '14 05:08

conlustro


People also ask

How do you remove text before or after a specific character in Google Sheets?

RIGHT+LEN+FIND. There are a few more Google Sheets functions that let you remove the text before a certain character. They are RIGHT, LEN and FIND.

How do I change all occurrences of a word in Google Sheets?

On your computer, open a spreadsheet in Google Sheets. Find and replace. Next to "Find," type the word you want to find, If you want to replace the word, enter the new word next to "Replace with."

How do I automatically replace text in Google Sheets?

How do you use REPLACE in Google Sheets? To use REPLACE in Google Sheets, you simply need to type =REPLACE( into the cell where you want to perform the replacement, and then input the text you want to replace, the text you want to replace it with, and the number of times you want it to occur.

How do you replace multiple characters in Google Sheets?

Find and Replace in Google Sheets Select the range where you want to replace values (here, B2:B19), and in the menu, go to Edit > Find and replace (or use the keyboard shortcut CTRL + H).


2 Answers

The * quantifier just needs to be applied to a dot (.) which will match any character.

enter image description here

To clarify: the * wildcard used in certain spreadsheet functions (eg COUNTIF) has a different usage to the * quantifier used in regular expressions.

like image 122
AdamL Avatar answered Sep 27 '22 17:09

AdamL


In addition to options that would be available in Excel (LEFT + FIND) pointed out by pnuts, you can use a variety of regex tools available in Google Sheets for text searching / manipulation

For example, RegexReplace:

=REGEXREPLACE(A1,"(.*)USD.*","$1")
  • (.*) <- capture group () with zero or more * of any character .
  • USD.* <- exact match on USD followed by zero or more * of any character .
  • $1 <- replace with match in first capture group

enter image description here

like image 32
KyleMit Avatar answered Sep 27 '22 18:09

KyleMit