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

150
Vistas
How would I get a discord tag from a string with regex?

I don't have basically any experience when it comes to regex, and have a basic understanding of string manipulation. I am trying to separate a discord tag from the rest of a string, but am running into issues.

For example, I was able to separate a tag like vunsh#3191 from 'vunsh#3191 has done blah blah blah`. But when a discord tag has a space in it or other characters, it doesn't detect it with the system I'm using right now.

Ex. My current system would get just vunsh's from vunsh's discord#1234 blah blah blah. I need vunsh's discord#1234

I found a method called string#match(), and it seems to be what I am looking for. What I am struggling with is what to put as the regex pattern that passes into #match().

Ex.

const paragraph = 'vunsh thing#2134 blah blah';
const regex = //what goes here?
const found = paragraph.match(regex);

console.log(found);
// expected output: Array ["vunsh thing#2134"]

Note: Not all the strings I am working with contain the word "vunsh", but all discord tags have a # and 4 numbers right after that.

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

0

You could use

const regex = /.*#\d{4}\b/g;

But this wont work in all cases where theres text before the username, for that there is no solution.

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