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

213
Vistas
regexp to get words up next, exists or not

This regexp is matching strings after /ab. Also, i would like to match empty strings after /ab. How can i do that?. Thanks in advance.

const TelegramBot = require('node-telegram-bot-api');
const token = process.env.TOKEN;
const bot = new TelegramBot(token, { polling: true });

bot.onText(/\/ab (.+)/, (msg, match) => {
    const chatId = msg.chat.id
    const prompt = match[1]
    bot.sendMessage(chatId, prompt)
})

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

0

Use a lookbehind: /^(?![\s\S])|(?<=\/ab).*/g

A lookbehind (?<=) will match anything in front of it without being included in the actual match. As for return an empty string, you'll need to explicitly return a "" if there's no match. You can change this line maybe: Added an alternate ^(?!\[\s\S\])|

const rgx = new RegExp(/^(?![\s\S])|(?<=\/ab).*/, 'g');

const str = `/ab 1234 hdsso
/abksdfsioiowe
/ab
khbigigi7 
s366s7d /ab`;

let matches = [...str.matchAll(rgx)].flat();

console.log(matches);

Regex101

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