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

138
Views
How to get the first 3 digits from a cell

So I have got a column and i want to get the first 3 digits only from it and store them in a function called wnS using the split function or any other method that would work. I want to get the first three digits before "_"

I tried doing this but it didn't work, and I also kept getting "TypeError: wnC.split is not a function"

    var ssh = ssPO.getSheetByName("PO for OR (East).csv")
    wnC = ssh.getRange("N2:N");
    var wnS = wnC.split("_");

enter image description here

I would really appreciate an answer

If you need more info please let me know

Thank you.

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

0

After you define range, you have to get the values.

function first_3_digs (){
    
        var ssh = ssPO.getSheetByName("PO for OR (East).csv")
        var wnC = ssh.getRange("N2:N");
        var values = wnC.getValues();
        const first_3_digs = values.filter(r => {
            if(r.toString().includes('_')){return r;}
        }).map(r=> r.toString().split('_')[0]);
        console.log(first_3_digs)
    }
about 4 years ago · Juan Pablo Isaza Report

0

const cell = "(303) 987-4567";
const first3 = cell.match(/\d{3}/)[0];
//result:303

String method match()

regular expression

BTW: you can test methods like this very easily in the console.log in the browsers developer tools.

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!