-3
4

1 回答 1

1

正则表达式是一个可怕的想法。但仍然 - 试试这个:@<a href="members/.+/" class="username bigs" title="">(.+)</a>@U

$subject = '..some code here..
<a href=\"members/username1.12345/\" class=\"username bigs\" title=\"\">Username 1</a>
..some code here..
..some code here..
<a href=\"members/username2.55334/\" class=\"username bigs\" title=\"\">Username 2</a>
..some code here..
..some code here..
<a href=\"members/username3.23455/\" class=\"username bigs\" title=\"\">Username 3</a>
..some code here..
..some code here..
<a href=\"members/username4.45545/\" class=\"username bigs\" title=\"\">Username 4</a>
..some code here..';

$pattern = '@<a href="members/.+/" class="username bigs" title="">(.+)</a>@U';

$result = preg_match_all($pattern, $subject, $subpattern);

echo '<pre>'.print_r($subpattern, TRUE).'</pre>';
于 2013-04-07T11:45:29.503 回答