Toren
Toren

Reputation: 6856

perl - regular expression - match case

Hi I have some file that looks like this:

some row
/folder1/folder2/folder3/folder4/folder5  *.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

Upvotes: 1

Views: 217

Answers (1)

jb.
jb.

Reputation: 10341

\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

Upvotes: 1

Related Questions