Well, the first thing that I spot is that the resulting regex wil have two "+" at the end: /(\s*([a-z][a-z0-9\-]*)\s*:\s*([a-z][a-z0-9\-]*)\s*;)++/i Could that be it? Doug Green wrote:
I'm pretty good with regex, but I'm beating my head against the wall with this one, and wondering if there's a bug in php.
Any help is much appreciated. (This is for nicedit.)
<?php $text = 'style="font-style: italic; font-weight: bold;"'; $regex = "(\s*([a-z][a-z0-9\-]*)\s*:\s*([a-z][a-z0-9\-]*)\s*;)+"; if (preg_match('/'. $regex .'+/i', $text, $matches)) { print_r($matches); } ?>
If the regex is confusing, just think of it simply as ((\w+):(\w+);)+ ... with extra spaces and a definition for words that includes dashes.
The regex vars $1 and $2 seem to only put the last matching value in the matches array.
Array ( [0] => font-style: italic; font-weight: bold; [1] => font-weight: bold; [2] => font-weight [3] => bold )
I was hoping that it would also write font-style: italic into the matches.
Thanks, Doug Green