Regular Expressions 101

Community Patterns

1...56789...587

Task 4 Quiz

2

Regular Expression
PCRE2 (PHP >=7.3)

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 - a year ago