in reply to Regexp issue
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.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Regexp issue
by QuasarD (Novice) on Feb 22, 2018 at 15:52 UTC | |
by hippo (Archbishop) on Feb 22, 2018 at 16:10 UTC |