I have this regular exrpression:
'#<div>(.+?)</div>#s'
which gets everything inside a div pair.
I want to get just the number inside this div's.
Regex to find a number inside divs
Moderator: General Moderators
-
klevis miho
- Forum Contributor
- Posts: 413
- Joined: Wed Oct 29, 2008 2:59 pm
- Location: Albania
- Contact:
- ridgerunner
- Forum Contributor
- Posts: 214
- Joined: Sun Jul 05, 2009 10:39 pm
- Location: SLC, UT
Re: Regex to find a number inside divs
what number?
-
klevis miho
- Forum Contributor
- Posts: 413
- Joined: Wed Oct 29, 2008 2:59 pm
- Location: Albania
- Contact:
Re: Regex to find a number inside divs
any number
- ridgerunner
- Forum Contributor
- Posts: 214
- Joined: Sun Jul 05, 2009 10:39 pm
- Location: SLC, UT
Re: Regex to find a number inside divs
This one will find the first multi-digit integer following an opening div before a closing div, and capture that number into group 1:
Code: Select all
$re = '%<div>(?:(?!</div>|\d).)*(\d+)%s';