hth
John
#!/usr/bin/perl $file="theinputfile"; undef $/; #In order to read the whole file at once open(F,"$file"); $f = <F>; my @matches = $f =~ m{ ( /\* .*? \*/) | ( \/\/[^\n]*) | " (?: [^"\\]* | \\. )* " | ' (?: [^'\\]* | \\. )* ' | . [^/"']* }xgs; @matches = grep {defined $_} @matches; #get rid of undefs my $linenum = 1; foreach my $match (@matches) { # $slurpedfile =~ /\Q$match/; $f =~ /\Q$match/; my $before = $`; # $slurpedfile = $'; $f = $'; my $matched = $&; $linenum += $before =~ tr/\n/\n/; print "Line $linenum\t$match\n"; $linenum += $match =~ tr/\n/\n/; }
In reply to Re: Re: Re: Regex Strikes again!
by johndageek
in thread Regex Strikes again!
by nofernandes
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |