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

266
Vistas
RegEx for string starts with number and followed by + character

I want a regular expression for such inputs:

1+2
3
1+22+3

But If I write following inputs then it should not allow. Such as;

+1+2
1+
a+1+b+c
12+

The string must start with number and then followed by only + character. But After the + character, it has to be any number. I tried this [^0-9][^+]? but İt deletes the + sign at the start with the regex I wrote, but there is a problem. While deleting the + character, it also removes the number next to it. This event keeps repeating.

How can I do this?

over 4 years ago · Santiago Trujillo
2 Respuestas
Responde la pregunta

0

Please try :

\d+(\+\d)*

Demo: https://regex101.com/r/hfqmYr/2

Where:

\d -> Matches with any digit

+ -> Matches a symbol one or more times

* -> Matching a symbol 0 or many times

over 4 years ago · Santiago Trujillo Denunciar

0

As mentioned in the comments, it looks like you can use:

^[0-9]+(?:\+[0-9]+)*$

This is to allow the mentioned sample data and discard those you don't want to allow. See an online demo. The pattern matches:

  • ^ - Start line anchor.
  • [0-9]+ - 1+ Digits (ASCII).
  • (?:\+[0-9]+)* - 0+ Times a non-capture group to allow for a literal plus followed by 1+ digits (ASCII).
  • $ - End line anchor.

As per my knowledge .NET requires you to explicitly mention these ASCII digits to avoid matching numbers from other languages (unless specified otherwise using ECMAScript options).

over 4 years ago · Santiago Trujillo 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