<div dir="ltr">On Fri, Jul 25, 2008 at 4:39 PM, Todd Walton <span dir="ltr">&lt;<a href="mailto:tdwalton@gmail.com">tdwalton@gmail.com</a>&gt;</span> wrote:<br><div class="gmail_quote"><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div class="Ih2E3d">On Fri, Jul 25, 2008 at 3:07 PM, Chris Freeman &lt;<a href="mailto:cwfreeman@gmail.com">cwfreeman@gmail.com</a>&gt; wrote:<br>
&gt; \b(|D|PP)\d{1,3}(,{0,1}\d{3})*<br>
<br>
</div>You&#39;ll miss the first 999 patents. &nbsp;I&#39;m guessing that&#39;s not gonna<br>
matter, but couldn&#39;t you make character 13 above be a zero instead of<br>
a one?<br>
</blockquote><div><br>I&#39;m not sure how it&#39;s going to miss the first 999 patents. It matches 88, and 999, etc, just fine in my tests.<br><br>But, \b also matches a comma, so you&#39;d need something like:<br>(\s|^)(|D|PP)\d{1,3}(,{0,1}\d{3})*(\s|$)<br>
<br>I&#39;m using &quot;\s&quot; to match spaces, which may not be a valid assumption.<br>However, it does correctly match all of the examples set forth (including 1, 12, and 123).<br><br>Chris<br><br>
$ cat tmp.pl<br>
#!/usr/bin/perl<br>
while(&lt;STDIN&gt;) {<br>
&nbsp;&nbsp;&nbsp; if( $_ =~ /(\s|^)(|D|PP)\d{1,3}(,{0,1}\d{3})*(\s|$)/ ) {<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; print &quot;Match\n&quot;;<br>
&nbsp;&nbsp;&nbsp; } else {<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; print &quot;No match\n&quot;;<br>
&nbsp;&nbsp;&nbsp; }<br>
}<br><br>
$ perl tmp.pl<br>
1<br>
Match<br>
A1<br>
No match<br>
D1<br>
Match<br>
PP1<br>
Match<br>
12<br>
Match<br>
A12<br>
No match<br>
D12<br>
Match<br>
PP12<br>
Match<br>
123<br>
Match<br>
A123<br>
No match<br>
D123<br>
Match<br>
PP123<br>
Match<br>
1234<br>
Match<br>
A1234<br>
No match<br>
D1234<br>
Match<br>
PP1234<br>
Match<br>
1,234<br>
Match<br>
A1,234<br>
No match<br>
D1,234<br>
Match<br>
PP1,234<br>
Match<br>
12,345,678<br>
Match<br>
A12,345,678<br>
No match<br>
D12,345,678<br>
Match<br>
PP12,345,678<br>
Match<br>
12,34,56<br>
No match<br>
12,345,678,<br>
No match<br>
<br>
<br></div></div><br></div>