Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

259
Visualizações
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 Respostas
Responde à pergunta

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 Relatório

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda