Note that there are some explanatory texts on larger screens.

plurals
  1. PORegExp infinite loop only in perl, why?
    primarykey
    data
    text
    <p>I have a regular expression to test whether a CSV cell contains a correct file path:</p> <p><strong>EDIT</strong> The CSV lists filepaths that does not yet exists when script runs (I cannot use -e), and filepath can include * or %variable% or {$variable}.</p> <pre><code>my $FILENAME_REGEXP = '^(|"|""")(?:[a-zA-Z]:[\\\/])?[\\\/]{0,2}(?:(?:[\w\s\.\*-]+|\{\$\w+}|%\w+%)[\\\/]{0,2})*\1$'; </code></pre> <p>Since CSV cells sometimes contains wrappers of double quotes, and sometimes the filename itself needs to be wrapped by double quotes, I made this grouping (|"|""") ... \1</p> <p>Then using this function:</p> <pre><code>sub ValidateUNCPath{ my $input = shift; if ($input !~ /$FILENAME_REGEXP/){ return; } else{ return "This is a Valid File Path."; } } </code></pre> <p>I'm trying to test if this phrase is matching my regexp (It should not match):</p> <pre><code>"""c:\my\dir\lord" </code></pre> <p>but my dear Perl gets into infinite loop when:</p> <pre><code>ValidateUNCPath('"""c:\my\dir\lord"'); </code></pre> <p><strong>EDIT</strong> actually it loops on this:</p> <pre><code>ValidateUNCPath('"""\aaaaaaaaa\bbbbbbb\ccccccc\Netwxn00.map"'); </code></pre> <p>I made sure in <a href="http://regexpal.com" rel="nofollow">http://regexpal.com</a> that my regexp correctly catches those non-symmetric """ ... " wrapping double quotes, but Perl got his own mind :(</p> <p>I even tried the /g and /o flags in </p> <pre><code>/$FILENAME_REGEXP/go </code></pre> <p>but it still hangs. What am I missing ? </p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload