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

285
Vistas
How do i write a RegEx that starts reading from behind?

I have a series of words I try to capture.

I have the following problem:

  • The string ends with a fixed set of words
  • It is not clearly defined how many words the string consists of. However, it should capture all words that start with a upper case letter (German language). Therefore, the left anchor should be the first word starting with lower case.

Example (bold is what I try to capture):

  • I like Apple Bananas And Cars.

  • building houses Might Be Salty + Hard said Jessica.

This is the RegEx I tried so far, it only works, if the "non-capture" string does not include any upper case words: /(?:[a-zäöü]*)([\p{L} +().&]+[Cars|Hard])/gu

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

0

You might start the match with an uppercase character allowing German uppercase chars as well, and then optionally repeat matching either words that start with an uppercase character, or a "special character.

Then end the match with an alternation matching either Hard or Cars.

(?<!\S)[A-ZÄÖÜß][a-zA-ZäöüßÄÖÜẞ]*(?:\s+(?:[A-ZÄÖÜß][a-zA-ZäöüßÄÖÜẞ]*|[+()&]))*\s+(?:Hard|Cars)\b

Explanation

  • (?<!\S) Assert a whitespace boundary to the left to prevent starting the match after a non whitespace char
  • [A-ZÄÖÜß][a-zA-ZäöüßÄÖÜẞ]* Match a word that starts with an uppercase char
  • (?: Non capture group to match as a whole part
    • \s+ Match 1+ whitespace chars
    • (?: Non capture group
      • [A-ZÄÖÜß][a-zA-ZäöüßÄÖÜẞ]* Match a word that starts with uppercase
      • | Or
      • [+()&] Match one of the "special" chars
    • ) Close the non capture group
  • )* Close the non capture group and optionally repeat it
  • \s+ Match 1+ whitespace chars
  • (?:Hard|Cars) Match one of the alternatives
  • \b A word boundary to prevent a partial word match

See a regex demo.

about 4 years ago · Juan Pablo Isaza Denunciar

0

Use \p{Lu} for uppercase letters:

(?:[\p{Lu}+()&][\p{L}+()&]* )+(?:Cars|Hard)

See live demo (showing matching umlauted letters and ß).

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