David Angel
David Angel

Reputation: 991

Why is preg_match_all() returning empty matches array?

Regex pattern: /{if\s+(isRegion|isCountry)([a-z]+?)}/i

Expected matches:

{if isRegionAsia}

{if isRegionEurope}

{if isCountryChina}

Working example here: http://regex101.com/r/gL4qN9/2

Why, then, in PHP, does preg_match_all() return an array with 3 empty results instead of the matches? What am I missing here? Thanks in advance for any help!

Upvotes: 0

Views: 479

Answers (2)

David Angel
David Angel

Reputation: 991

Turns out it was working all along.

::slowly backs away::

Upvotes: -1

TML
TML

Reputation: 12966

'/{if\s+(isRegion|isCountry)([a-z]+?)}/i' works just fine for me. See it in action here.

Upvotes: 1

Related Questions