Jump to content

any number except 7[0-9]{4}


michaellunsford

Recommended Posts

See if this works for the rest of your dataset. I changed the max to 7 since you said "1095012" should match--it is 7 numbers, not 6.

[code]
<pre>
<?php
$tests = array(
"78876 555 easy street", ### should return "555"
"1095012 LBJ Highway, 71231", ### should return "1095012"
"7000 East Main Street" ### should return "7000"
);
foreach ($tests as $test) {
preg_match('/\b(?!7\d{4})\d{1,7}\b/', $test, $matches);
print_r($matches);
}
?>
</pre>

[/code]
Link to comment
Share on other sites

[quote author=effigy link=topic=122751.msg506671#msg506671 date=1169011514]I changed the max to 7 since you said "1095012" should match--it is 7 numbers, not 6.
[/quote]

odd, my PHP reads it like this [1]{6}=7

Great it works! Now, what's the difference between [0-9] and \d? preference, or is it more than that?
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.