what does preg_match_all("/<option\svalue\s='([^']+)'>([^>]+)<\/option>/", $txt, $rs); do? I understand it matches the pattern but what is all the extra back slashes, '\s', '([^', etc. mean. thanks for any help!
\s is any whitespace character. See the PCRE Escape sequences page in the PHP manual for a list http://nz.php.net/manual/en/regexp.reference.escape.php [^']+ says one or more characters that are not apostrophes. It's fairly standard for regular expression syntaxes and is probably documented in a page close to the one above HTH Bruce
so assuming that $txt=<option value='423122' >Della 1</option> would this be the expected array: $rs[0]=<option value='423122' >Della 1</option> $rs[1]=value='423122' >Della 1</option> $rs[2]=='423122' >Della 1</option> $rs[3]=423122' >Della 1</option> I am not sure what the rest would be
Try this <?php $txt="<option value='423122' >Della 1</option>"; $rs=array(); $pat="/<option\s+value\s*=\s*'([^']+)'[^>]*>([^<]*)<\/option>/"; print "preg_match\n"; print preg_match( $pat, $txt, $rs ) . " "; print $txt . "\n"; print_r( $rs ); print "\n\n"; print "preg_match_all\n"; print preg_match_all( $pat, $txt, $rs ) . " "; print $txt . "\n"; print_r( $rs ); Code (markup): Output preg_match 1 <option value='423122' >Della 1</option> Array ( [0] => <option value='423122' >Della 1</option> [1] => 423122 [2] => Della 1 ) preg_match_all 1 <option value='423122' >Della 1</option> Array ( [0] => Array ( [0] => <option value='423122' >Della 1</option> ) [1] => Array ( [0] => 423122 ) [2] => Array ( [0] => Della 1 ) ) Code (markup): Neither of these are exactly your expected output. The preg_match output seems to be closer to it than the preg_match. HTH Bruce
Yes, Sorry I forgot to mention that I'd done that. I got carried away with finding out what the differences were between the output of preg_match_all and preg_match and by the time I wrote up my results it had slipped my mind that I'd had to debug the pattern at the start of the process. I hope it didn't take you too long to work out that I'd changed it. Bruce