regex html parsing

Any questions involving matching text strings to patterns - the pattern is called a "regular expression."

Moderator: General Moderators

Post Reply
excultus
Forum Newbie
Posts: 5
Joined: Fri Jul 28, 2006 9:29 am

regex html parsing

Post by excultus »

hello i need to use this
<div id=res>(.*?)</div>
in eregi() but it gives me REG_BADRPT, could somebody help me please?
it should return the contents of the tag
thanks much :)
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

Don't use ereg*.. use preg_match(_all)
User avatar
GeertDD
Forum Contributor
Posts: 274
Joined: Sun Oct 22, 2006 1:47 am
Location: Belgium

Re: regex html parsing

Post by GeertDD »

excultus wrote:hello i need to use this
<div id=res>(.*?)</div>
in eregi() but it gives me REG_BADRPT, could somebody help me please?
it should return the contents of the tag
thanks much :)
You could try escaping the star and/or the question mark like below. The error goes away, but you still need to test it.

Code: Select all

var_dump(eregi('<div id=res>(.\*\?)</div>', '<div id=res>tag</div>'));
You really should go for the PCRE functions as feyd said!
Post Reply