Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

204
Vistas
How to retrieve single quote words form sentence in javascript?

var str = `Then I should 'create' 'adhoc payments' on '01' working day of pay period '04' of 'Current' Fiscal`
var spilitArr = str.split(" ");
var filterArr = spilitArr.filter(e=>e.includes("'"));

// s.match(/'([^']+)'/)[1];
console.log(spilitArr, 'spilitArr')
console.log(filterArr, 'filterArr')

console.log(`expected array:' , ['create' 'adhoc payments', '01', '04', 'Current']`)

Tried multiple ways, can any one help me.

about 4 years ago · Juan Pablo Isaza
3 Respuestas
Responde la pregunta

0

You were kind of barking up the right tree with your RegExp attempt; a pattern like /(?<=\W').+?(?='\W)/g will probably get you to where you need to be to meet your requirement:

var str = `Then I should 'create' 'adhoc payments' on '01' working day of pay period '04' of 'Current' Fiscal`
const pattern = /(?<=\W').+?(?='\W)/g;
const matches = str.match(pattern);
console.log(matches);

about 4 years ago · Juan Pablo Isaza Denunciar

0

var str = `Then I should 'create' 'adhoc payments' on '01' working day of pay period '04' of 'Current' Fiscal`
const pattern = /'(.*?)'/g;
const matches = str.match(pattern).map(e => e.substring(1,e.length-1))
console.log(matches);

about 4 years ago · Juan Pablo Isaza Denunciar

0

var str = `Then I should 'create' 'adhoc payments' on '01' working day of pay period '04' of 'Current' Fiscal`;
let res = [];

for( let a=0; a<str.length; a++ ){
  const sqOpen = str.indexOf("'", a);
  const sqClose =( sqOpen !== -1 )? str.indexOf("'", sqOpen+1):-1;
  if( sqClose !== -1 ){
    a = sqClose + 1;
    res.push( str.slice(sqOpen+1, sqClose ) );
  }else{
    break;
  }
}
console.log(res);

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda