On Sunday 18 August 2002 08:29, vic wrote:
> Ok, since I've been trying to get this working forever, how wold you get
> something like this working I need, to get everything between these 2
> tags:
> <div class=Section1> and </div>
> Someone gave me this code:
> preg_match('!<div class=Section1[^>]+>(.*)</div>!Uis',$str,$regs);
> with the ! in front, and !Uis at the end, what does that mean?

It's good that someone else does the work for, but it's also good to read the 
documentation as well. All these regexes has what is called a delimiter, 
everything that is enclosed within the delimiter is the expression. In most 
cases the '/' is used as the delimiter. But if you're trying to match '/' in 
your expression (as in your case you're looking for </div>) then it makes 
sense to use a different delimiter, one that ideally is not used in your 
expression. Thus the above use of '!'. The 'Uis' are modifiers and modify 
matching behaviour (rtfm).

> And when i try it with your script:
> preg_match('/.*<div class=Section1[^>]+>(.*)</div>.*/',$str,$regs);
> $good = $regs[1];
> echo $good;
> I get:
> Warning: Unknown modifier 'd' in
> /home/victor/argilent-www/sites/malibu_place_2/main.php on line 197

Hopefully from the above explanation you can see that:

  /.*<div class=Section1[^>]+>(.*)</div>.*/'

here you're using '/' as the delimiter. Thus everything between the first 2 
'/' is the expression, ie:

  .*<div class=Section1[^>]+>(.*)<

Whatever is after the 2nd '/' is treated as a modifier, and hence your 
warning, unknown modifier.

Jason Wong -> Gremlins Associates -> www.gremlins.com.hk
Open Source Software Systems Integrators
* Web Design & Hosting * Internet & Intranet Applications Development *

What the scientists have in their briefcases is terrifying.
                -- Nikita Khruschev

PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to