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

162
Vistas
RegEx for capturing ticket ID's in a URL

I'm attempting to craft a RegEx that will isolate the ticket ID numbers in my URL and send them back to me in a bug report as seen below.

  const input = document.getElementById('nameInput')
        data = {
          "name": input.value || "Problem with ticket"+ window.location.href.match(/\d/),
          "story_type" : "Bug",
          "description": window.location.href

I have also tried pulling the whole URL

 "Problem with ticket"+ window.location.href.match(/https?:\/\/(www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_\+.~#?&//=]*)/)

However, both return "Problem with ticket Null", I admit I'm terrible at RegEx, so what would be the best way to write this? I've attached an example URL below.

https://xoxoxox.zendesk.com/agent/tickets/2116248
about 4 years ago · Juan Pablo Isaza
3 Respuestas
Responde la pregunta

0

If there can be more digits in the url, you can make it specific to get it after tickets in a capture group.

Check first if there is a match, and then get the capture group 1 value:

\/tickets\/(\d+)

Regex demo

let m = "https://xoxoxox.zendesk.com/agent/tickets/2116248".match(/\/tickets\/(\d+)/);
if(m) {
  console.log(m[1]);
}

Output

2116248
about 4 years ago · Juan Pablo Isaza Denunciar

0

If ticket ID is only digits.

"https://xoxoxox.zendesk.com/agent/tickets/2116248".replace(/.*\/(\d*)/,"$1")

Result : 2116248

about 4 years ago · Juan Pablo Isaza Denunciar

0

You can try the following RegEx \d+ for retrieving the required ID,

As demonstrated in the code snippet below,

url = "https://xoxoxox.zendesk.com/agent/tickets/2116248";

let ticketID = url.match(/\d+/);
console.log(ticketID);

Read more about it 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