Eily is right, you should not have the braced term within the character class.

m/^"{1}[^"{1}]/ # ^^^ ^^^-This is wrong # | # This is unnecessary

If you are testing the same thing (here that a string matches a certain regex) more than once, don't write the code out more than once as (a) you might not type it the same in error and (b) if you make changes you need to do them twice. This is called DRY in the jargon.

Taking both of these into account, and assuming you just want to match a leading double-quote followed by something other than a double-quote, here's an altered version of your code showing both date strings matching:

use strict; use warnings; use feature 'say'; my @strings = ('"18/02/2018"', '"28/02/2018"'); for (@strings) { say if /^"[^"]/; }

You can of course expand on this by putting other values into @strings and see if they match or not. If it gets any fancier, try turning it into a test instead with Test::More.


In reply to Re: Regexp issue by hippo
in thread Regexp issue by QuasarD

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.