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

259
Views
How to remove specific multiple string and then remain another?
let result = 'Apple%00Juice%02';

const removeOne = result.slice(5, 8); // get %00

const removeTwo = result.slice(13, 16); // get %02

slice get the part of I want to remove not I want to get.

Is any function can let me get the result becomes to 'Apple Juice' ?

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

0

You can get the desired result using a regex to match the parts you want to remove from the string and then replace them using the replace() method on strings.

const str = "Apple%00Juice%02";
const regex = /%\d+/g;

const result = str.replace(regex, " ").trim()

console.log(result);

Explanation of regex:

  • % - match the character % literally
  • \d+ - match any digit 0 to 9 one or more times
  • %\d+ - match % character followed by one or more digits
about 4 years ago · Juan Pablo Isaza Report

0

You can achieve this by using .replace() function

Example:

let result = 'Apple%00Juice%02';
result = result.replace('%00', ' ');
result = result.replace('%02', '');
console.log(result);

Read More About .replace() function at MDN Docs

Edit:

Minifying @Yousaf's Answer

let result = "Apple%00Juice%02";
result = result.replace(/%\d+/g, " ").trim()

console.log(result);

about 4 years ago · Juan Pablo Isaza Report

0

It is possible with replace(), but that is not a sustainable solution. The URL encoding "% 00" is the � ASCII character. This suggests that the string is already being encoded in the wrong character format for the URL. So you have to look at the character format in which your database or file is read out. for example UTF-8, ISO 8859-1

When encoded in the correct character format. Can you decode it in JavaScript using the decodeURIComponent (str) method. more on this

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!