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

91
Views
Displaying a part of a string

I get logs from the api in the format shown below. How do I just display the part after the last \n and time. The digits are time. Can it be done with some array methods or would I need regex here?

1645549901022 Running\n1645549901022 Process started\n1645549901022 START - Cloning repo\n1645549934999 Removed dumps

The part that I want to display is just Removed dumps

edit: \n is getting ignored so I think I would need to match the last digits/time

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

0

One line:

const input = '1645549901022 Running\n1645549901022 Process started\n1645549901022 START - Cloning repo\n1645549934999 Removed dumps';
const output = input.split(/[\n(\d+)]+/);

console.log(output[output.length-1].trim());

Result: Removed dumps

about 4 years ago · Juan Pablo Isaza Report

0

This is an example:

<script>
   logString = "1645549901022 Running\n1645549901022 Process started\n1645549901022 START - Cloning repo\n1645549934999 Removed dumps";

   arr = logString.split(" ");
    text = arr[arr.length-1] + ' ' +  arr[arr.length-2];
    alert(text);
</script>
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!