Community Patterns

Community Library Entry

3

Regular Expression
Created·2022-10-21 23:39
Flavor·PCRE2 (PHP)

Description

It needs a major modification, since matching an integer is required. The accepted answer \d+ involves only "positive" integers. But -333 or +777 are also integers, which leads to two possible solutions with the last one being the most accurate:

-?\d+ : The hyphen (optional minus sign) and a digit 1 or more times. To include the negatives.

[+-]?\d+ : Optional + or - and the quantity of more than 0 digits.`

Submitted by seQuienSoy