Hi,
not sure I understand what you want...
This is how I interpret your code (pls. use code tags by the way):
#!/usr/bin/perl use strict; use warnings; my $string = "abcABC123ABCabc"; # the following is using shell commands # to do something perl can do much better... echo `expr match "$string" 'abc[A-Z]*.2'` ; echo `expr match "$string" 'abc[A-Z]*2'` ;
As said - not sure what your intention is.

To test a regex, you'd use something like:
#!/usr/bin/perl use strict; use warnings; my $string = "abcABC123ABCabc"; print "Regex1: ", $string =~ /abc[A-Z]*.2/, "\n" ; print "Regex2: ", $string =~ /abc[A-Z]*2/, "\n";
Result:
Regex1: 1 Regex2:
Reason: The first matches any number of uppercase characters, followed by 1 character then followed by a 2 (this regex matched once in the string, therefore 1). The second matches any number of A-Z followed by a 2 - as there is a 1 inbetween, it doesn't match.
Maybe you look after .* which will match any number of any character???
Regards,
svenXY

In reply to Re: difference between "*." and "." operators by svenXY
in thread difference between "*." and "." operators by vaibhav4947

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • 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:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.