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

203
Vistas
Javascript Regular expression to match text between a colon sign and sentences ended by a dot

Suppose I have a text like this:

This is the title: \ titles always have a colon
This is a regular sentence.
A sentence always ends with a period.
A sentence can
span multiple lines.
A sentence can contain numbers like 123.
The phrase can also contain "text enclosed in double quotes" or 'text enclosed in single quotes'.
Other symbols that may appear in sentences are
the comma ,
the semicolon ;
the dollar sign $
parentheses ( )
the plus sign + the minus sign - and the square brackets[ ].

This is an isolated phrase that the regular expression should not match.

How could I create a regex in javascript to match the text between the first colon* and the last full stop after brackets[ ]? (assuming there will be no other colon, if there are any, they will be enclosed in double quotes)

I've tried using :.* but it maches all lines.

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

0

Using the s flag, the following regex captures everything after the colon till the double linebreak.

/(?<=:).*?(?=(?:\r?\n)+[^\n]*$)/sg

Test on regex101 here

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