Search code examples
google-sheetsgoogle-sheets-formula

Extract substring after '-' character in Google Sheets


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)))}

enter image description here


Solution

  • 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 (-).

    Example

    Sample of RegExtract

    Reference