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

138
Vistas
Regex string contain just digits and *,#,+ in javascript

I am trying to implement a function in Javascript that verify a string. The pattern i must to do is contain only digits charactor, *, # and +. For example:

+182031203
+12312312312*#
+2131*1231#
*12312+#
#123*########

I tried alot of thing like

/^[\d]{1,}[*,#,+]{1,}$

but it's doesn't work. I am not sure that i understand good in regex. Please help.

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

0

I think you want the pattern ^[0-9*#+]+$:

var inputs = ["+182031203", "+12312312312*#", "+2131*1231#", "12312+#", "#123########"];
for (var i=0; i < inputs.length; ++i) {
    console.log(inputs[i] + " => " + /^[0-9*#+]+$/.test(inputs[i]));
}

about 4 years ago · Juan Pablo Isaza Denunciar

0

Using Regex101

/^[0-9\*\#\+]+$/g

0-9 matches a single character in the range between 0 (index 48) and 9 (index 57) (case sensitive) * matches the character * with index 4210 (2A16 or 528) literally (case sensitive) # matches the character # with index 3510 (2316 or 438) literally (case sensitive) + matches the character + with index 4310 (2B16 or 538) literally (case sensitive)

about 4 years ago · Juan Pablo Isaza Denunciar

0

Try this regular expression:

const rxDigitsAndSomeOtherCharacters = /^(\d+|[*#]+)+$/;

Breaking it down:

  • ^ start-of-text, followed by
  • ( a [capturing] group, consisting of
    • \d+ one or more digits
    • | or...
    • [*#+]+ one ore more of *, # or +
  • )+, the [capturing] group being repeated 1 or more times, and followed by
  • $ end-of-text
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