in reply to string matching condition not working fine
Can you tell us what you're getting, and what you're expecting? This seems to work fine for me...
This produces:while (my $line = <DATA>) { chomp $line; if ($line =~ /(#include)( ")([^g]\w+)(\.)(\w+")/) { print "$. MATCH [$line]\n"; } else { print "$. not match [$line]\n" } } __DATA__ not an include #include "foo.h" #include <foo.h> #include "gfoo.h"
1 not match [not an include] 2 MATCH [#include "foo.h"] 3 not match [#include <foo.h>] 4 not match [#include "gfoo.h"]
|
|---|