Regular Expressions 101

Community Patterns

Get Numbers from an x of z sentence

1

Regular Expression
PCRE (PHP <7.3)

/
([1-9]+) of ([0-9]+)
/

Description

If you have a sentence in a log file like "2 of 4 pictures converted successfully" and you need to know the numbers you can use this regex and use the group variable.

Submitted by Kai - 8 years ago