Hi I have some file that looks like this:
some row
/folder1/folder2/folder3/folder4/f开发者_开发知识库older5 *.kuku.* noku
/folder1/folder2/folder3/folder4/folder5 *.kuku noku
another row
another row
if first line is absent I need to add it, if second line is absent I need to add only second line
I wrote regular expressions , but they are not really works:
if ($line =~ /(\*\.kuku\.\*\b)/) {do something}
if ($line =~ /(\*\.kuku\b)/) {do something else}
Any idea? Thanks
\b
only matches on word boundaries. \*\.kuku\.\*\b
will never match because *
is not a word character.
You could change it to \s
so you match a whitespace. \*\.kuku\.\*\s
精彩评论