I am using the following formula to extract the substring venue01
from column C, the problem is that when value string in column C is shorter it only extracts the value 1 I need it to extract anything straight after the -
(dash) no matter the length of the value text in column c
={"VenueID";ARRAYFORMULA(IF(ISBLANK(A2:A),"",RIGHT(C2:C,SEARCH("-",C2:C)-21)))}
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.
Extract data before a certain text — LEFT+SEARCH Whenever you want to extract data that precedes a certain text, use LEFT + SEARCH: LEFT is used to return a certain number of characters from the beginning of cells (from their left) SEARCH looks for certain characters/strings and gets their position.
There is a much simpler solution using regular expressions.
=REGEXEXTRACT(A1,".*-(.*)")
In case you are no familiar with Regular Expressions what this means is, get me every string of characters ((.*)
) after a dash (-
).
REGEXTRACT
To answer bomberjackets question in the comment of Raserhin:
To select the part of the string before the "-"
=REGEXEXTRACT(A1,"(.*)-.*")
EXAMPLE
example of code
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With