You are here: Re: A (hopefully) simple regular expression question... « PHP Programming Language « IT news, forums, messages
Re: A (hopefully) simple regular expression question...

Posted by Justin Koivisto on 01/12/06 22:53

Al wrote:
> I just tested this and i get fieldset not closed for all 3 cases
> (fieldset works properly, no fieldset was used at all and fieldset not
> closed)

Really?? Here's what I get:

<?php
$str=array();
$str[]=<<<EOS
<fieldset>
<legend>&nbsp;Bob&nbsp;</legend>
<div class="quote">Hello there</div>
</fieldset>

EOS;

$str[]=<<<EOS
<fieldset>
<legend>&nbsp;Bob&nbsp;</legend>
<div class="quote">Hello there</div>

EOS;

$str[]=<<<EOS
<legend>&nbsp;Bob&nbsp;</legend>
<div class="quote">Hello there</div>

EOS;

$pattern='`<fieldset>.*</fieldset>`isU';

foreach($str as $html){
echo $html,"---\n";
if(preg_match($pattern,$html)){
// fieldset is closed
echo 'fieldset closed',"\n\n";
}else{
// fieldset set is *not* closed
echo 'fieldset not closed',"\n\n";
}
}
?>


Result:
<fieldset>
<legend>&nbsp;Bob&nbsp;</legend>
<div class="quote">Hello there</div>
</fieldset>
---
fieldset closed

<fieldset>
<legend>&nbsp;Bob&nbsp;</legend>
<div class="quote">Hello there</div>
---
fieldset not closed

<legend>&nbsp;Bob&nbsp;</legend>
<div class="quote">Hello there</div>
---
fieldset not closed


--
Justin Koivisto, ZCE - justin@koivi.com
http://koivi.com

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация