in reply to Compiled regular expression using qr

> but it does not seem to work.

Why? Can you show us code?

> dont understand why, "?^i" part got added

Cause you appended /i which means case insensitive.

The way a compiled regex is stringified changed between Perl versions, but that doesn't mean they work differently now.

Cheers Rolf

(addicted to the Perl Programming Language and ☆☆☆☆ :)

  • Comment on Re: Compiled regular expression using qr

Replies are listed 'Best First'.
Re^2: Compiled regular expression using qr
by perlbaski (Sexton) on Oct 15, 2014 at 20:48 UTC
    Thanks!,

    I tired printing both origVal and critVal

    data_123 and (?^:data_123)

    Apparently data_123 != ?^:data_123 I removed case insensitive in my query string.

      In the OP and in your reply above, you use the terms "exact" and "case insensitive" in the context of regex matching in a way that leads me to wonder if you understand that case insensitive matching is inherently inexact. E.g.:

      c:\@Work\Perl>perl -wMstrict -le "my $rx = qr/^data_123$/i; print $rx; ;; for my $s (qw(data_123 DATA_123 dAtA_123 data_123x data_12 nada_123) +) { if ($s =~ $rx) { print qq{'exact' match to '$s'}; } else { print qq{NO match to '$s'}; } } " (?^i:^data_123$) 'exact' match to 'data_123' 'exact' match to 'DATA_123' 'exact' match to 'dAtA_123' NO match to 'data_123x' NO match to 'data_12' NO match to 'nada_123'

      Update: I should have mentioned that the example above was run under Strawberry Perl version 5.14.4.1.

        My bad, I reinitialized the variable as part of debugging, no wonder it would not match.

        Thanks for clarifying on its use. That said, the stringify version has ?^ in front, I know that ? means 0 or more of the chars preceding it, but what does ?^ mean?