in reply to Re^2: Regex to detect file name
in thread Regex to detect file name

I actually just changed the =~ to !~ and it works as expected with your regex.

I don't understand from the OP what you want, and so I don't understand how the logical negation of Corion's regex gives you what you want. Can you elucidate, perhaps with some matching and non-matching example strings? Are you sure you're really matching what you think you're matching? (Please see perlre, perlretut, and perlrequick.)


Give a man a fish:  <%-{-{-{-<

Replies are listed 'Best First'.
Re^4: Regex to detect file name
by Laurent_R (Canon) on Jul 05, 2018 at 21:56 UTC
    Hm, I think I understand the problem. The OP's regex:
    if($view_tag =~ m/[^A-Za-z0-9_\-\.]/) {
    actually has a negative character class (leading ^), rather than a start-of-string anchor.

    So the OP had to negate the pattern.

    My guess is that the OP really meant:

    if($view_tag =~ m/^[A-Za-z0-9_\-\.]/) {
    Update: fixed a typo: s/or-string/of-string/
      My guess is that the OP really meant ...

      My guess is that your guess is probably pretty good, but lirc201 is the only one who can clear this up and I doubt we'll hear much more from that quarter. I guess this is just another mystery to be filed in the big, empty drawer labeled X. :)


      Give a man a fish:  <%-{-{-{-<