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

138
Vistas
construir una matriz basada en un texto con delimitador de caracteres

Tengo dificultades para crear una función genérica donde una entrada sería una cadena que contiene un volumen de texto grande o pequeño y la salida es una matriz y tengo muchos problemas con esta complejidad, pero cada posición de la matriz debe contener 125 caracteres como máximo y no puede tener una palabra rota, por ejemplo, si hay alguna palabra final con la que se debe pasar 125 caracteres a la siguiente posición de la matriz.

Ejemplo:

Valor de entrada: `var text =" Lorem Ipsum is simply a text simulation of the printing and printing industry, and has been in use since the 16th century, when an unknown printer took a tray of typefaces and shuffled them together to make a type model book Lorem Ipsum survived not only five centuries but also the leap into desktop publishing, remaining essentially unchanged It became popular in the 1960s when Letraset launched decals containing passages of Lorem Ipsum, and more recently when is now integrated with desktop editing software like Aldus PageMaker." `

Valor de salida incorrecto: `[ "Lorem Ipsum is simply a text simulation of the printing and printing industry, and it has been in use since the century," "XVI, when a printer discovered a type tray and shuffled them together to make a typeface template book."] `

Tenga en cuenta que la posición 0 de la matriz ha pasado de 125 debido a la palabra "siglo".

Valor de salida correcto: `[" Lorem Ipsum is simply a text simulation of the printing and printing industry, and has been in use since the "," 16th century, when an unknown printer took a tray of typefaces and shuffled them to make a book of models of "," types. Lorem Ipsum survived not only five centuries, but also the leap into desktop publishing, remaining ", ...]`

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

0

Puede usar la expresión regular .{1,125}\b que busca con avidez entre 1 y 125 caracteres seguidos de un límite de palabra:

 const regex = /.{1,125}\b/g; var text =" Lorem Ipsum is simply a text simulation of the printing and printing industry, and has been in use since the 16th century, when an unknown printer took a tray of typefaces and shuffled them together to make a type model book Lorem Ipsum survived not only five centuries but also the leap into desktop publishing, remaining essentially unchanged It became popular in the 1960s when Letraset launched decals containing passages of Lorem Ipsum, and more recently when is now integrated with desktop editing software like Aldus PageMaker."; console.log(text.match(regex));

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