HomeGoogle DocsSpreadsheetGoogle Sheets LEFT, RIGHT Functions and Alternative REGEXEXTRACT

Google Sheets LEFT, RIGHT Functions and Alternative REGEXEXTRACT

Published on

Unlike Google Sheets REGEX text functions, LEFT, RIGHT functions are very straightforward to use. So little to learn the use of it. Further, you can replace both LEFT, RIGHT functions with REGEXEXTRACT.

First, I’m moving to the syntax part of the LEFT, RIGHT functions and then directly jumping to the alternative REGEXEXTRACT formula.

Google Sheets LEFT Function – Syntax

We can use Google Sheets LEFT function to return a specific number of characters from the left side of a String.

Syntax:

LEFT(string, [number_of_characters])

The below LEFT formula would return “INFO” the first four characters of the string.

=LEFT("INFO INSPIRED",4)

Google Sheets RIGHT Function – Syntax

The RIGHT function returns a specific number of characters from the right side of a specified string.

Syntax:

RIGHT(string, [number_of_characters])

The below RIGHT formula would return “INSPIRED” the last eight characters of the string.

=RIGHT("INFO INSPIRED",8)

See how we can replace or avoid LEFT, RIGHT functions with other functions in Google Sheets.

MID Function as an Alternative to LEFT, RIGHT functions in Google Sheets

You can use MID text function as an alternative to Google Sheets LEFT as well as RIGHT functions. Here is the example.

The below MID formula would return the word “INFO” which is equal to the above LEFT formula.

=MID("INFO INSPIRED",1,4)

The following MID formula would return the word “INSPIRED” similar to the above RIGHT formula.

=MID("INFO INSPIRED",6,8)

Now more interesting part of this tutorial. You can simply use REGEXEXTRACT as an alternative to Google Sheets LEFT as well as RIGHT functions.

See How REGEXEXTRACT Replaces LEFT, RIGHT Functions.

The following REGEXEXTRACT formula is equal to the LEFT formula above. It returns the first four characters from the string “INFO INSPIRED”

=REGEXEXTRACT("INFO INSPIRED","....")

Now you can similarly use REGEXEXTRACT to replace RIGHT function. The below formula would return the last 8 characters from the string.

=REGEXEXTRACT("INFO INSPIRED","(........\z)")

Practical Use of LEFT, RIGHT Functions

I am limiting this part to only one example as an effort to cut short this tutorial.

Let’s check how to find unique texts in a list when first few characters are only matching. Didn’t get? See the screenshot.

unique text based on first few characters

The above are few drawing numbers. I want to find the unique drawings based on the first 6 characters.

=ArrayFormula(countunique(left(A1:A6,6)))

See the formula. Here I’ve used the LEFT function in conjunction with COUNTUNIQUE and it would return the result as # 2.

Prashanth KV
Prashanth KV
Your Trusted Google Sheets and Excel Guide Prashanth KV brings a wealth of experience in Google Sheets and Excel, cultivated through years of work with multinational corporations in Mumbai and Dubai. As a recognized Google Product Expert in Docs Editors, Prashanth shares his expertise through insightful blogging since 2012. Explore his blog for practical tips and guidance on maximizing your spreadsheet skills.

Interactive Random Task Assigner in Google Sheets

You have multiple tasks and multiple people. Here's a fun way to randomly assign...

Google Sheets Bar and Column Chart with Target Coloring

To color each data point in the column or bar chart according to the...

Analyzing Column A Between Non-Adjacent Values in Column B: Google Sheets

This tutorial addresses a common scenario encountered in Google Sheets: how to sum, average,...

Excel Word Count: Beyond SUBSTITUTE

You might want to count the number of words in a cell in Excel...

More like this

Interactive Random Task Assigner in Google Sheets

You have multiple tasks and multiple people. Here's a fun way to randomly assign...

Google Sheets Bar and Column Chart with Target Coloring

To color each data point in the column or bar chart according to the...

Analyzing Column A Between Non-Adjacent Values in Column B: Google Sheets

This tutorial addresses a common scenario encountered in Google Sheets: how to sum, average,...

5 COMMENTS

  1. Hello,

    Is there a way to use the left, right function with the Query function?
    I’m trying to take YYYYMMDD in the B column, number format into YYYY-MM-DD as date format by query with text function…

    Thank you!

LEAVE A REPLY

Please enter your comment!
Please enter your name here

This site uses Akismet to reduce spam. Learn how your comment data is processed.