I'm using PHP, and am hoping to be able to create a regex that finds and returns the street number portion of an address.
Example:
1234- South Blvd. Washington D.C., APT #306, ZIP45234
In the above example, only 1234 would be returned.
Seems like this should be incredibly simple, but I've yet to be successful. Any help would be greatly appreciated.
Try this:
$str = "1234- South Blvd. Washington D.C., APT #306, ZIP4523";
preg_match("~^(\d+)~", $str, $m);
var_dump($m[1]);
string(4) "1234"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With