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

140
Views
Vuejs: Handling slicing of select results
let slug = 'test-value/2';
let slug = 'test-value-data/10';
let slug = 'test-number-data/100';
let slug = 'data-test/1000';
let slug = 'test/10000';

For example, each time I select, I will get 1 slug as above. Now I want to trim the string from /number. For example, I want to trim the string test-value/2 to test-value. So how to cut the string from / onwards. And common to all slugs. Please give me your opinion, Thank you.

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

0

Try to replace it using regex as shown in the following example :

let slug='test-value/2'
let trimmedSlug=slug.replace(/\/.*/i,'')
console.log(trimmedSlug)

about 4 years ago · Juan Pablo Isaza Report

0

You can use .split()

Note: Use this method if the slug will always have a format of <slug without '/'>/<number>

// Using .split();

let slug = 'test-value/2';
const trimmedSlug = slug.split('/')[0];

console.log(trimmedSlug);

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!