Extract Substring After '-' Character in Google Sheets

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

2 Answers

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

Reference

1

To answer bomberjackets question in the comment of Raserhin:

To select the part of the string before the "-"

=REGEXEXTRACT(A1,"(.*)-.*")

EXAMPLE

example of code

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Marcus Vance
Author

Marcus Vance

Marcus Vance is a cybersecurity auditor and technology writer dedicated to educating the public about online safety, data privacy regulations, enterprise security, and emerging cyber threats.