Well I'd like to point out that you aren't really making use of preg_replace!

I would recommend you use:

str_replace($search, $replace, $subject)

instead, as you aren't actually using an expression.

Example of a regular expression (NOTE: the slashes around my expression):

PHP Code:

```
<?php
```

$values = "

5/25/11<x>07/02/09<x>BLDG.<x>BL555<x>BL555<x>BL555<x>

BL555<x>BL555<x>BL313<x>BL313<x>BL313<x>BL313<x>BL313<x>

BL313<x>BL313<x>BL313<x>BL529<x>BL529<x>BL529<x>BL529<x>

BL529<x>BL529<x>BL493<x>BL493<x>BL493<x>BL493<x>BL513<x>

BL513<x>BL513<x>BL513<x>BL513<x>BL551<x>BL519<x>BL519d<x>

BL519<x>BL519<x>BL539<x>BL539<x>BL539<x>BL539<x>BL523<x>

BL551<x>BL549C<x>BL549<x>BL549G<x>BL550<x>BSC150<x>BSC150<x>

BL547<x>BL547<x>BL547<x>BL547<x>BL543<x>BL543<x>BL543<x>

BL543<x>BL543<x>BL543<x>BL543<x>BL433<x>BL433<x>BL433<x>

BL433<x>BL433<x>BL433<x>BL439<x>BL439<x>BL437<x>BL441<x>

BL453<x>BL453<x>BL453<x>BL453<x>BL455<x>BL455<x>BL455<x>

BL456<x>BL456<x>BL456<x>BL461<x>BL461<x>BL461<x>BL462<x>

BL462<x>BL462<x>BL463<x>BL463<x>BL463<x>BL463<x>BL463<x>

BL454<x>BL454<x>BL454<x>BL454<x>BL454<x>BL277<x>BL277<x>

BL277<x>BL275<x>BL275<x>BL275<x>BL276<x>BL276<x>BL276<x>

BL276<x>BL280<x>BL280<x>BL280<x>BL272<x>BL272<x>BL272<x>

BL271<x>BL271<x>BL304<x>BL304<x>BL304<x>BL001<x>BL001<x>

BL299<x>This should fail!!<x>This too<x>BlahBlah9<x>BL299

<x>BL299<x>BL299<x>BLDG. #<x>BL299<x>BL299<x>BL299<x>BL299

<x>BL299<x>BL257<x>BL257<x>BL257<x>BL257<x>BL257<x>BL257<x>

BL257C<x>BL257C<x>BL257C<x>BL223<x>BL223<x>BL223<x>BL221<x>

BL221<x>BL221<x>BL227<x>BL2/(\w+) (\d+), (\d+)/i27<x>BL227

<x>BL227<x>BL227<x>BL227<x>BL243<x>BL243<x>BL243<x>BL243<x>

BL243<x>BL243<x>BL243<x>BL243<x>BL243<x>BL243<x>BL243<x>

BL243<x>BL237<x>BL237<x>BL237<x>BL237<x>BL237<x>BL404B<x>

BL045<x>BL045<x>BL045<x>BL045<x>BL043<x>BL043<x>BL043<x>

BL047<x>BL047<x>BL047<x>BL672<x>BL672<x>BL672<x>BL672";

$values = explode("<x>", str_replace("\n",'',$values));

foreach($values as $k => $v) {

if(preg_match("/^B[LSGCD]{1,2}[0-9]{3}[A-Z]{0,1}/", $v)) {

echo '<br /><span style="color:green;">', $v, "</span>";

} else {

echo '<br /><span style="color:red;">', $v, "</span>";

}

}

?>

Cheers