I have some products with pre defined sequence numbers. I want to write a pattern which will look for sequence numbers Greater than predefined.
For example in the below mentioned code:
$ProdBuild = 'K7000AKNBJQ4333';
My regular expression should match if for any product the last 4 digits are greater than or equal to 4333.
Matching Patterns:
$ProdBuild = 'K7000AKNBKQ4333';
$ProdBuild = 'K7000A-KNBKQ-4333';
$ProdBuild = 'K7000A-KNBKQ-6801';
$ProdBuild = 'K7000TKNBKQ7610';
Non-matching Patterns:
$ProdBuild = 'K7000AKNBKQ4233';
$ProdBuild = 'K7000AKNB4333';
$ProdBuild = 'K7000ANBKQ6845';
$ProdBuild = 'K7000TKNBKQ-1845';
The following code is good except that it can't look for the ones with last 4 digits greater than a specified number. Could some one help me in this part?
use strict;
use warnings;
no warnings qw(once);
{
my $ProdBuild = 'K7000AKNBJQ4333';
if ($ProdBuild =~ m/K7000[A-Z]\-?[A-Z][A-Z][A-Z][A-Z][A-Z]\-?[4-9]
+[3-9]\d+/i) {
print "Product match $ProdBuild \n"
}
else {
print "No match found \n"
}
}
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.