开发者

perl - regular expression - match case

开发者 https://www.devze.com 2023-02-15 20:56 出处:网络
Hi I have some file that looks like this: some row /folder1/folder2/folder3/folder4/f开发者_开发知识库older5*.kuku.* noku

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

0

精彩评论

暂无评论...
验证码 换一张
取 消