1

This is my regex:

^.+\/.+\.sql.+$

it matches

/somedir/abc.sql.20121212

but it doesn't match

/somedir/abc.sql20121212 
/somedir/abc.sql_20121212

What am I doing wrong? Shouldn't sql.+$ mean match 'sql' and at least one of any character after it?

UPDATE: The above regex does indeed work. I was getting unexpected results because I hadn't saved the config file in which the regex is stored (DUH !!) The previous value was ^.+\/.+\.sql\..+$ which means has to be 'sql.' and at least one of any character after it. Sorry for the false alarm.

4

1 回答 1

2

实际上,它们确实匹配:

print "$_: ", /^.+\/.+\.sql.+$/ ? 'match' : 'no match', "\n"
   for qw(
      /somedir/abc.sql.20121212
      /somedir/abc.sql20121212 
      /somedir/abc.sql_20121212
   );

输出

/somedir/abc.sql.20121212: match
/somedir/abc.sql20121212: match
/somedir/abc.sql_20121212: match
于 2012-12-13T00:24:50.003 回答