Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

258
Views
How to get only the last string from cells in one column

I'm trying to get the last String (from the right hand side) of the cells in a column but I cant figure it out.

I have this code that would get the first three digits from the left hand side but yeah that wont work.

var first_3_digs = values.filter(r => {
                                                                                    if(r.toString().includes('_')){return r;}
                                                                                }).map(r=> r.toString().split('_')[0]);

enter image description here

For example if I want as an input CS_1*44u i want the output u. Same for ml, l etc...

If you need more info please let me know.

Thank you so much for the help.

about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

Example how to get the 'units' from several cells:

const unit = x => /[\d]+[\D]+/.test(x) ? x.match(/[A-z]+$/)[0] : '';

var texts = ['CS_1*44u', 'Case', '72x64ml', '11x37kg', '123'];

texts.forEach(x => console.log(unit(x))); // --> 'u', '', 'ml', 'kg', ''

Example how to get the 'unit' from one cell:

const unit = x => /[\d]+[\D]+/.test(x) ? x.match(/[A-z]+$/)[0] : '';

var cell_value = 'CS_1*44u';

console.log(unit(cell_value)); // --> 'u'

If you need to get the array of the 'units' from another array of cells you can map the function this way:

const unit = x => /[\d]+[\D]+/.test(x) ? x.match(/[A-z]+$/)[0] : '';

var cells = ['CS_1*44u', 'Case', '72x64ml', '11x37kg', '123'];

var units = cells.map(x => unit(x)); // <---- here

console.log(units); // --> ['u', '', 'ml', 'kg', '']

about 4 years ago · Juan Pablo Isaza Report

0

as you have tagged formulas for possible solution, i will offer the following REGEXEXTRACT formula:

=REGEXEXTRACT(K1,"[^(\d+(\.\d+)?)(?!.*\d+(\.\d+)?)]*$")

explanation:

AFTER last occurrence of "a":

[^a]*$

LAST digit (with or without decimal):

(\d+(\.\d+)?)(?!.*\d+(\.\d+)?)

enter image description here

[EDIT]

where \d means a number, here is a (shorter) alternative which is also tested as working with the same dataset:

=REGEXEXTRACT(K1,"[^\d]*$")
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!