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

216
Views
Buscando eliminar cualquier valor después de :->

Estoy buscando eliminar cualquier valor después de ':->' en JavaScript. Por ejemplo, si 'Packet:->3', me gustaría almacenar "Packet:->" en la variable para poder usarlo antes de que se vea la declaración if. abajo. Más o menos estoy buscando eliminar cualquier dígito después de '>'

Estaba intentando lo siguiente, pero no tuve mucha suerte.

NTEremoved = NTE.indexOf(':->');

¿Cuál sería la mejor manera de hacer esto?

 if(NTE == 'Packet:->' || NTE == 'Serving:->' || NTE == 'Can/Carton/Bottle:->'){ }
about 4 years ago · Juan Pablo Isaza
3 answers
Answer question

0

División de cuerdas.

 const testStr1 = "Packet:->3"; const testStr2 = "BlahBlahBlah278:->Hello hello this is cool"; const result1 = testStr1.split(":->")[0] + ":->"; // split "splits" the string into an array based on the delimiter ":->"; the second part would be 3 const result2 = testStr2.split(":->")[0] + ":->"; console.log(result1); console.log(result2);

documentos

about 4 years ago · Juan Pablo Isaza Report

0

Haría algo como esto, para ocuparme también de los casos extremos (suponiendo que no te importe lo que viene después del primero :-> :

 let texts = ["Packet:->11", "Cat:->22", "Packet:->:->:->44"]; for (let text of texts) { console.log(text.replace(/(:->).*$/, "$1")) }

about 4 years ago · Juan Pablo Isaza Report

0

Como mencionó que intentó usar indexOf antes pero no lo hizo, le proporcionaré una forma de usar una combinación de indexOf y String.slice

 let string = "Serving:->3" //Indexof return the first index of an element so you have to add 3 (the length of ":->" let newstring = string.slice(0,string.indexOf(":->")+3) console.log(newstring)

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!