Regex to match an optional '+' symbol followed by any number of digits

regex

Solution

This should work

\+?\d+

Matches an optional `+` at the beginning of the line and digits after it

EDIT:

As of OP's request of clarification: 3423kk55 is matched because so it is the first part (3423). To match a whole string only use this instead:

^\+?\d+$

Problem

I want a regular expression to match a string that may or may not start with plus symbol and then contain any number of digits. Those should be matched ``` +35423452354554 or 3423564564 ```

Original source