Regular Expressions 101

Community Patterns

Community Library Entry

1

Regular Expression
PCRE (PHP <7.3)

/
^((i[A-Z][a-z]+)(( )([A-Z]?[a-z]+))?)(\s+)?((\d{1,2})([GSsce]{0,3}))?(\s+?)?(Plus)?$
/
gm

Description

Matches iOS device names. Groups and example matches: 0: Full device name ("iPhone 6s Plus") 1: Device name+class ("iPad Air") 2: Device name ("iPad") 3: Device class with preceding whitespace (" Mini") 4: Whitespace preceding device class (" ") 5: Device class ("Pro") 6: Whitespace before version/generation (" ") 7: Full version/generation ("3GS") 8: Major version/generation ("6") 9: Minor version/generation ("s") 10: Whitespace before size modifier (" ") 11: Size modifier ("Plus")

Submitted by Ben Leggiero - 9 years ago