Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

267
Views
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 answers
Answer question

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 Report

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!